List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:TextFieldViews.java
public static void displayView(View view, int indent, Document doc, PrintStream out) { String name = view.getClass().getName(); for (int i = 0; i < indent; i++) { out.print("\t"); }// w ww. j a v a 2 s. com int start = view.getStartOffset(); int end = view.getEndOffset(); out.println(name + "; offsets [" + start + ", " + end + "]"); int viewCount = view.getViewCount(); if (viewCount == 0) { int length = Math.min(32, end - start); try { String txt = doc.getText(start, length); for (int i = 0; i < indent + 1; i++) { out.print("\t"); } out.println("[" + txt + "]"); } catch (BadLocationException e) { } } else { for (int i = 0; i < viewCount; i++) { displayView(view.getView(i), indent + 1, doc, out); } } }
From source file:avantssar.aslanpp.testing.Tester.java
private static void reportException(String message, Throwable e, PrintStream out) { out.print("Error: "); out.println(message); out.println(e.getMessage());/*from w w w .j a va2 s. co m*/ out.println(); Debug.logger.fatal(message, e); }
From source file:co.cask.tigon.DistributedMain.java
private static void usage(boolean error) { PrintStream out = (error ? System.err : System.out); out.println( "Usage: java -cp lib/*:<hadoop/hbase classpath> co.cask.tigon.DistributedMain <ZooKeeperQuorum> " + "<HDFSNamespace>"); out.println(/*from w w w. ja va2 s .c o m*/ "Example: java -cp lib/*:$HBASE_CLASSPATH co.cask.tigon.DistributedMain 165.238.239.12:1234/tigon " + "tigon"); out.println(""); if (error) { throw new IllegalArgumentException(); } }
From source file:ShowHTMLViews.java
public static void displayElement(Document doc, Element e, int indent, PrintStream out) { for (int i = 0; i < indent; i++) { out.print(" "); }//from ww w . ja v a 2 s .c o m out.println("===== Element Class: " + getShortClassName(e.getClass())); for (int i = 0; i < indent; i++) { out.print(" "); } int startOffset = e.getStartOffset(); int endOffset = e.getEndOffset(); out.println("Offsets [" + startOffset + ", " + endOffset + "]"); AttributeSet a = e.getAttributes(); Enumeration x = a.getAttributeNames(); for (int i = 0; i < indent; i++) { out.print(" "); } out.println("ATTRIBUTES:"); while (x.hasMoreElements()) { for (int i = 0; i < indent; i++) { out.print(" "); } Object attr = x.nextElement(); out.println(" (" + attr + ", " + a.getAttribute(attr) + ")" + " [" + getShortClassName(attr.getClass()) + "/" + getShortClassName(a.getAttribute(attr).getClass()) + "] "); } // Display the text for a leaf element if (e.isLeaf()) { try { String str = doc.getText(startOffset, endOffset - startOffset); if (str.length() > 40) { str = str.substring(0, 40); } if (str.length() > 0) { for (int i = 0; i < indent; i++) { out.print(" "); } out.println("[" + str + "]"); } } catch (BadLocationException ex) { } } // Display child elements int count = e.getElementCount(); for (int i = 0; i < count; i++) { displayElement(doc, e.getElement(i), indent + 1, out); } }
From source file:Main.java
static void dumpXpath(Node node, PrintStream printer) { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { Node item = list.item(i); printer.println("Xpath: " + getXPath(item)); printer.println("Text Content: " + item.getTextContent()); if (item.hasChildNodes()) { dumpXpath(item, printer);/*from w w w .j ava2 s . c o m*/ } } }
From source file:com.vaadin.sass.testcases.scss.W3ConformanceTests.java
public static void extractCSS(final URI url, File targetdir) throws Exception { /*/*from w w w .ja va 2 s .c om*/ * For each test URL: 1) extract <style> tag contents 2) extract from * <link rel="stylesheet"> files 3) extract inline style attributes from * all elements and wrap the result in .style {} */ Document doc = Jsoup.connect(url.toString()).timeout(20000).get(); List<String> tests = new ArrayList<String>(); for (Element e : doc.select("style[type=text/css]")) { tests.add(e.data()); } for (Element e : doc.select("link[rel=stylesheet][href][type=text/css]")) { URI cssUri = new URI(e.attr("href")); if (!cssUri.isAbsolute()) { cssUri = url.resolve(cssUri); } String encoding = doc.outputSettings().charset().name(); tests.add(IOUtils.toString(cssUri, encoding)); } for (Element e : doc.select("*[style]")) { tests.add(String.format(".style { %s }", e.attr("style"))); } for (final String test : tests) { targetdir.mkdirs(); String logfile = String.format("%s.%d.scss", FilenameUtils.getBaseName(url.toString()), tests.indexOf(test)); PrintStream dataLogger = new PrintStream(new File(targetdir, logfile)); dataLogger.println("/* Source: " + url + " */"); dataLogger.println(test); } }
From source file:Main.java
private static void destroyPid(int pid) { Process suProcess = null;//from ww w.j a v a2 s .c o m PrintStream outputStream = null; try { suProcess = Runtime.getRuntime().exec("su"); outputStream = new PrintStream(new BufferedOutputStream(suProcess.getOutputStream(), 8192)); outputStream.println("kill " + pid); outputStream.println("exit"); outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (outputStream != null) { outputStream.close(); } if (suProcess != null) { try { suProcess.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } } }
From source file:com.chinamobile.bcbsp.util.ClassLoaderUtil.java
/** * Bootstrap class path// w w w . ja v a2 s.com * * @param ps A PrintStream */ public static void listBootstrapClassPath(PrintStream ps) { ps.println("BootstrapClassPath:"); list(ps, getBootstrapClassPath()); }
From source file:com.chinamobile.bcbsp.util.ClassLoaderUtil.java
/** * System class path// w w w .j a va 2 s.co m * * @param ps A PrintStream */ public static void listSystemClassPath(PrintStream ps) { ps.println("SystemClassPath:"); list(ps, getSystemClassPath()); }
From source file:com.chinamobile.bcbsp.util.ClassLoaderUtil.java
/** * Ext class path//w w w. j av a2 s . c om * * @param ps A PrintStream */ public static void listExtClassPath(PrintStream ps) { ps.println("ExtClassPath:"); list(ps, getExtClassPath()); }