List of usage examples for java.io PrintWriter println
public void println(Object x)
From source file:com.alicloud.tablestore.adaptor.client.IntegratedTest.java
public static void printThreadInfo() { String title = "Automatic Stack Trace"; PrintWriter stream = new PrintWriter(System.out); int STACK_DEPTH = 20; boolean contention = threadBean.isThreadContentionMonitoringEnabled(); long[] threadIds = threadBean.getAllThreadIds(); stream.println("Process Thread Dump: " + title); stream.println(threadIds.length + " active threads"); for (long tid : threadIds) { ThreadInfo info = threadBean.getThreadInfo(tid, 20); if (info == null) { stream.println(" Inactive"); } else {// www . ja v a 2 s. c o m stream.println("Thread " + getTaskName(info.getThreadId(), info.getThreadName()) + ":"); Thread.State state = info.getThreadState(); stream.println(" State: " + state); stream.println(" Blocked count: " + info.getBlockedCount()); stream.println(" Waited count: " + info.getWaitedCount()); if (contention) { stream.println(" Blocked time: " + info.getBlockedTime()); stream.println(" Waited time: " + info.getWaitedTime()); } if (state == Thread.State.WAITING) { stream.println(" Waiting on " + info.getLockName()); } else if (state == Thread.State.BLOCKED) { stream.println(" Blocked on " + info.getLockName()); stream.println(" Blocked by " + getTaskName(info.getLockOwnerId(), info.getLockOwnerName())); } stream.println(" Stack:"); for (StackTraceElement frame : info.getStackTrace()) stream.println(" " + frame.toString()); } } stream.flush(); }
From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java
/** * Writes the class information as <a href="http://databionic-esom.sourceforge.net/user.html#File_formats">ESOM * cls</a> file./*from ww w . j av a 2 s. co m*/ */ public static void writeAsESOM(SOMLibClassInformation classInfo, String fileName) throws IOException, SOMLibFileFormatException { PrintWriter writer = FileUtils.openFileForWriting("ESOM class info", fileName); writer.println("% " + classInfo.numData); // write class index => class name mapping in header for (int i = 0; i < classInfo.numClasses(); i++) { writer.println("% " + i + " " + classInfo.getClassName(i)); } for (String element : classInfo.getDataNames()) { writer.println(element + "\t" + classInfo.getClassIndexForInput(element)); } writer.flush(); writer.close(); }
From source file:net.metanotion.sqlc.SqlcPhp.java
public static int makeMethod(final PrintWriter writer, final SQLMethod m, final AssignmentWrap qe, final int level, final int[] gensym, final int[] braces, final boolean retValue) { final int val = gensym[0]; gensym[0] += 1;//from ww w . ja v a 2 s . co m writer.println("\t\t$_" + (val) + " = new " + qe.result + "();"); /* final int gi = gensym[0]; final int init = gensym[0] + 1; gensym[0]+=2; writer.println("\t\t\tfinal net.metanotion.util.reflect.GetInitializer<" + qe.result + "> _" + gi + " = net.metanotion.util.reflect.ReflectiveFieldInitializer.getInitializer(" + qe.result + ".class, this.types);"); writer.println("\t\t\tfinal net.metanotion.util.reflect.Initializer<" + qe.result + "> _" + init + " = _" + gi + ".initializer();"); */ final Iterator<String> fields = qe.fields.iterator(); final Iterator<QueryExpr> qs = qe.exprs.iterator(); while (qs.hasNext()) { final QueryExpr q = qs.next(); final String field = fields.next(); int returnSymbol = makeMethod(writer, m, q, level, gensym, braces, false); writer.println("\t\t\t$_" + (val) + "->" + field + " = $_" + (returnSymbol) + ";"); } //writer.println("\t\t\treturn _" + init + ".instance();"); writer.println("\t\treturn $_" + (val) + ";"); while (braces[0] > 0) { writer.println("}"); braces[0]--; } return -1; }
From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java
/** Writes the class information to a file in SOMLib format. */ public static void writeAsSOMLib(HashMap<String, String> classInfo, HashSet<String> classNames, String fileName) throws IOException, SOMLibFileFormatException { ArrayList<String> classNamesList = new ArrayList<String>(classNames); Collections.sort(classNamesList); PrintWriter writer = FileUtils.openFileForWriting("SOMLib class info", fileName); writer.println("$TYPE class_information"); writer.println("$NUM_CLASSES " + classNames.size()); writer.println("$CLASS_NAMES " + StringUtils.toString(classNamesList, "", "", " ")); writer.println("$XDIM 2"); writer.println("$YDIM " + classInfo.size()); for (String key : classInfo.keySet()) { writer.println(key + " " + classNamesList.indexOf(classInfo.get(key))); }//from w w w . j ava2s . co m writer.flush(); writer.close(); }
From source file:at.tuwien.ifs.somtoolbox.data.InputDataWriter.java
/** Writes the class information to a file in SOMLib format. */ public static void writeAsSOMLib(SOMLibClassInformation classInfo, String fileName) throws IOException, SOMLibFileFormatException { PrintWriter writer = FileUtils.openFileForWriting("SOMLib class info", fileName); writer.println("$TYPE class_information"); writer.println("$NUM_CLASSES " + classInfo.numClasses()); writer.write("$CLASS_NAMES "); for (int i = 0; i < classInfo.numClasses(); i++) { writer.write(classInfo.getClassName(i)); if (i + 1 < classInfo.numClasses()) { writer.write(" "); }//from ww w . j av a 2s . co m } writer.println(); writer.println("$XDIM 2"); writer.println("$YDIM " + classInfo.numData); for (String element : classInfo.getDataNames()) { writer.println(element + " " + classInfo.getClassName(element)); } writer.flush(); writer.close(); }
From source file:edu.uci.ics.asterix.result.ResultUtils.java
public static void webUIParseExceptionHandler(PrintWriter out, Throwable e, String query) { String errorTemplate = readTemplateFile("/webui/errortemplate_message.html", "<pre class=\"error\">%s\n</pre>"); String errorOutput = String.format(errorTemplate, buildParseExceptionMessage(e, query)); out.println(errorOutput); }
From source file:net.sf.firemox.database.DatabaseFactory.java
/** * Save the cache into the database XML file. *//*from ww w . j a v a 2 s . co m*/ public static void saveCache() { if (config != null) { try { PrintWriter printer = new PrintWriter( Configuration.loadTemplateTbsFile(IdConst.FILE_DATABASE_SAVED)); printer.println(CACHE_FILE_HEADER); config.print(printer); IOUtils.closeQuietly(printer); } catch (IOException e) { // Cache could not be saved e.printStackTrace(); } } }
From source file:gov.nih.nci.evs.browser.utils.ViewInHierarchyUtils.java
private static void println(PrintWriter out, String text) { out.println(text); }
From source file:Main.java
/** * Performs the actual recursive dumping of a DOM tree to a given * <CODE>PrintWriter</CODE>. Note that dump is intended to be a detailed * debugging aid rather than pretty to look at. * /*www . ja v a2 s. c o m*/ * @param out The <CODE>PrintWriter</CODE> to write to. * @param node The <CODE>Node</CODE> under consideration. * @param indent The level of indentation. * @see #dump(PrintWriter, Node) * @since TFP 1.0 */ private static void doDump(PrintWriter out, final Node node, int indent) { if (node != null) { for (int index = 0; index < indent; ++index) out.write(' '); switch (node.getNodeType()) { case Node.DOCUMENT_NODE: { Document document = (Document) node; out.println("DOCUMENT:"); doDump(out, document.getDoctype(), indent + 1); doDump(out, document.getDocumentElement(), indent + 1); break; } case Node.DOCUMENT_TYPE_NODE: { DocumentType type = (DocumentType) node; out.println("DOCTYPE: [" + "name=" + format(type.getName()) + "," + "publicId=" + format(type.getPublicId()) + "," + "systemId=" + format(type.getSystemId()) + "]"); break; } case Node.ELEMENT_NODE: { Element element = (Element) node; out.println("ELEMENT: [" + "ns=" + format(element.getNamespaceURI()) + "," + "name=" + format(element.getLocalName()) + "]"); NamedNodeMap attrs = element.getAttributes(); for (int index = 0; index < attrs.getLength(); ++index) doDump(out, attrs.item(index), indent + 1); for (Node child = element.getFirstChild(); child != null;) { doDump(out, child, indent + 1); child = child.getNextSibling(); } break; } case Node.ATTRIBUTE_NODE: { Attr attr = (Attr) node; out.println("ATTRIBUTE: [" + "ns=" + format(attr.getNamespaceURI()) + "," + "prefix=" + format(attr.getPrefix()) + "," + "name=" + format(attr.getLocalName()) + "," + "value=" + format(attr.getNodeValue()) + "]"); break; } case Node.TEXT_NODE: { Text text = (Text) node; out.println("TEXT: [" + format(text.getNodeValue()) + "]"); for (Node child = text.getFirstChild(); child != null;) { doDump(out, child, indent + 1); child = child.getNextSibling(); } break; } case Node.CDATA_SECTION_NODE: { CDATASection data = (CDATASection) node; out.println("CDATA: [" + format(data.getNodeValue()) + "]"); break; } case Node.COMMENT_NODE: { Comment comm = (Comment) node; out.println("COMMENT: [" + format(comm.getNodeValue()) + "]"); break; } default: out.println("UNKNOWN: [type=" + node.getNodeType() + "]"); break; } } }
From source file:expansionBlocks.ProcessCommunities.java
private static void printTopologicalExtension(Query query, Map<Entity, Double> community) throws FileNotFoundException, UnsupportedEncodingException { File theDir = new File("images"); if (!theDir.exists()) { boolean result = theDir.mkdir(); }/*from w w w . jav a2 s .c om*/ PrintWriter writer = FileManagement.Writer .getWriter("images/" + query.getId() + "TopologicalCommunity.txt"); writer.println("strict digraph G{"); Set<Entity> entitySet = community.keySet(); Set<Long> categoriesSet = new HashSet<>(); for (Entity e : entitySet) { categoriesSet.addAll(Article.getCategories(e.getId())); } Map<Long, Double> categoryWeightMap = new HashMap<>(); Double maxW = 0.0; for (Entity entity : entitySet) { Long entityID = entity.getId(); maxW = maxW < community.get(entityID) ? community.get(entityID) : maxW; Set<Long> neighbors = Article.getNeighbors(entityID, Graph.EDGES_OUT); Collection<Long> intersection = CollectionUtils.intersection(neighbors, entitySet); for (Long neighbourID : intersection) { if (!Article.isARedirect(entityID) && !Article.isARedirect(neighbourID)) { writer.println(entityID + " -> " + neighbourID + " [color=red];"); } } Set<Long> categories = Article.getCategories(entityID); for (Long categoryID : categories) { writer.println(entityID + " -> " + categoryID + " [color=green];"); Double w = categoryWeightMap.put(categoryID, community.get(entityID)); if (w != null && w > community.get(entityID)) categoryWeightMap.put(categoryID, w); } Set<Long> redirects = Article.getRedirections(entityID); /* for (Long redirectID : redirects) { if (!Article.isARedirect(articleID)) { } }*/ } for (Long categoryID : categoriesSet) { Set<Long> neighbors = Category.getNeigbors(categoryID, Graph.EDGES_OUT); Collection<Long> intersection = CollectionUtils.intersection(neighbors, categoriesSet); for (Long neighbourID : intersection) { writer.println(categoryID + " -> " + neighbourID + " [color=blue];"); } neighbors = Category.getNeigbors(categoryID, Graph.EDGES_IN); intersection = CollectionUtils.intersection(neighbors, categoriesSet); for (Long neighbourID : intersection) { writer.println(neighbourID + " -> " + categoryID + " [color=blue];"); } } for (Entity entity : entitySet) { String title = entity.getName(); title = Normalizer.normalize(title, Normalizer.NFD); title = title.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); title = title.replaceAll("[.]+", " "); //writer.println(id + "[label=\"" + title + "\"];"); // String weight = new BigDecimal(community.get(id)*10).toPlainString(); BigDecimal weightDouble = new BigDecimal(2 / maxW * community.get(entity) + .5); String weight = weightDouble.toPlainString(); writer.println(entity + "[label=\"" + title + "\", width=" + weight + ", height=" + weight + " fixedsize=true,style=filled,color=\"#c0c0c0\"];"); } for (Long id : categoriesSet) { String title = (new Category(id)).getName(); title = Normalizer.normalize(title, Normalizer.NFD); title = title.replaceAll("\\p{InCombiningDiacriticalMarks}+", ""); title = title.replaceAll("[.]+", " "); BigDecimal weightDouble = new BigDecimal(2 / maxW * categoryWeightMap.get(id) + .5); String weight = weightDouble.toPlainString(); writer.println(id + "[label=\"" + title + "\", width=" + weight + ", height=" + weight + " fixedsize=true,style=filled,color=\"#f0f0f0\"];"); } writer.println("}"); writer.close(); }