本文整理匯總了Java中java.io.PrintStream.println方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintStream.println方法的具體用法?Java PrintStream.println怎麽用?Java PrintStream.println使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.io.PrintStream
的用法示例。
在下文中一共展示了PrintStream.println方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: printThreadInfo
import java.io.PrintStream; //導入方法依賴的package包/類
private void printThreadInfo(ThreadInfo ti, PrintStream out) {
printThread(ti, out);
// print stack trace with locks
StackTraceElement[] stacktrace = ti.getStackTrace();
MonitorInfo[] monitors = ti.getLockedMonitors();
for (int i = 0; i < stacktrace.length; i++) {
StackTraceElement ste = stacktrace[i];
out.println(INDENT + "at " + ste.toString()); // NOI18N
for (MonitorInfo mi : monitors) {
if (mi.getLockedStackDepth() == i) {
out.println(INDENT + " - locked " + mi); // NOI18N
}
}
}
out.println();
}
示例2: emitOptionKind
import java.io.PrintStream; //導入方法依賴的package包/類
private void emitOptionKind(ArrayList<Record> options, PrintStream os)
throws Exception
{
emitSourceFileHeaderComment("Option Kinds definitions for Jlang driver", os);
os.printf("package xcc;%n%n");
os.println("//This class defines some sort of static Constant for representing Option Kind.");
os.println("public interface OptionKind");
os.println("{");
int i = 0;
TreeSet<String> kinds = new TreeSet<>();
for (Record opt : options)
{
kinds.add(opt.getValueAsDef("Kind").getValueAsString("Name"));
}
for (String kind : kinds)
{
os.printf("\tint KIND_%s = %d;%n", kind, i++);
}
os.println("}\n\n");
}
示例3: print_comparison
import java.io.PrintStream; //導入方法依賴的package包/類
public static void print_comparison(PrintStream s, String name,
Stats ref_stats, Stats new_stats, boolean terse)
{
// Print only if there is at least one data point.
if (ref_stats.n() + new_stats.n() > 0)
{
if (! terse)
{
print(s, name, ref_stats);
print(s, name, new_stats);
}
if (ref_stats.n() > 0 && new_stats.n() > 0)
{
s.println(format_percent_change(name, ref_stats,
new_stats));
}
}
}
示例4: saveGeo
import java.io.PrintStream; //導入方法依賴的package包/類
private void saveGeo(File file) throws IOException
{
if(file.exists())
{
file.delete();
}
else
{
file.mkdirs();
file.delete();
}
file.createNewFile();
PrintStream ps = new PrintStream(file);
for(Triangle t: geo)
{
ps.println(t);
}
ps.close();
}
示例5: formatDeployableMappingMessage
import java.io.PrintStream; //導入方法依賴的package包/類
public static JSONObject formatDeployableMappingMessage(JSONObject org, JSONObject space, JSONObject app, String apiUrl, JSONArray gitData, PrintStream printStream) {
try {
JSONObject deployableMappingMessage = new JSONObject();
deployableMappingMessage.put("Org" , org);
deployableMappingMessage.put("Space" , space);
deployableMappingMessage.put("App" , app);
deployableMappingMessage.put("ApiEndpoint" , apiUrl);
deployableMappingMessage.put("Method" , "POST");
deployableMappingMessage.put("GitData" , gitData);
return deployableMappingMessage;
} catch (Exception e) {
printStream.println("[IBM Cloud DevOps] Error: Failed to build Deployable Mapping Message.");
e.printStackTrace(printStream);
throw e;
}
}
示例6: print
import java.io.PrintStream; //導入方法依賴的package包/類
public void print(PrintStream stream, boolean printID) {
if (printID) {
stream.print(getId() + " ");
}
stream.printf("uncommon trap %s %s %s\n", bytecode, getReason(), getAction());
int indent = 2;
for (int j = 0; j < jvmsMethods.size(); j++) {
for (int i = 0; i < indent; i++) {
stream.print(' ');
}
stream.println("@ " + jvmsBCIs.get(j) + " " + jvmsMethods.get(j));
indent += 2;
}
}
示例7: usage
import java.io.PrintStream; //導入方法依賴的package包/類
public static void usage(PrintStream out) {
out.println("usage:");
out.println(" java -jar J2DAnalyzer.jar [Option]*");
out.println();
out.println("where options are any of the following in any order:");
out.println(" -Help|-Usage "+
"print out this usage statement");
out.println(" -Group:<groupname> "+
"the following result sets are combined into a group");
out.println(" -NoGroup "+
"the following result sets stand on their own");
out.println(" -ShowUncontested "+
"show results even when only result set has a result");
out.println(" -Graph "+
"graph the results visually (using lines of *'s)");
out.println(" -Best "+
"use best time within a resultset");
out.println(" -Worst "+
"use worst time within a resultset");
out.println(" -Average|-Avg "+
"use average of all times within a resultset");
out.println(" -MidAverage|-MidAvg "+
"like -Average but ignore best and worst times");
out.println(" <resultfilename> "+
"load in results from named file");
out.println();
out.println("results within a result set "+
"use Best/Worst/Average mode");
out.println("results within a group "+
"are best of all result sets in that group");
}
示例8: filterPerPackage
import java.io.PrintStream; //導入方法依賴的package包/類
public void filterPerPackage (PrintStream p, TreeSet<LSDFact> ontheflyDeltaKB, LSDFact packageF) {
// for a given package, start putting facts for all dirty elements within the package
for (String kind: typeLevel.keySet()) {
for (LSDFact typeF: typeLevel.get(kind)) {
if (typeF.getBindings().get(2).getGroundConst().equals(
packageF.getBindings().get(0).getGroundConst())) {
if (filter.typeLevel && p!=null) p.println("\t" + typeF);
if (filter.typeLevel) ontheflyDeltaKB.add(typeF);
filterPerType(p, ontheflyDeltaKB, typeF);
}
}
}
}
示例9: logClusterHistory
import java.io.PrintStream; //導入方法依賴的package包/類
/**
* loggs the cluster history to the loggging using the clusterLogger
*/
private void logClusterHistory(Cluster c) {
PrintStream s = clusterLogger.getLogStream();
if (s == null) {
return;
}
// s.println("case " + c.getClusterNumber());
s.println("case " + clusterCounter++);
s.print("path=[");
java.util.List<ClusterPathPoint> path = c.getPath();
for (ClusterPathPoint p : path) {
s.print(p + ";");
}
s.println("];");
}
示例10: printProcessErrorOutput
import java.io.PrintStream; //導入方法依賴的package包/類
/** Prints child process error output into the desired PrintStream.
*
* @param printTo PrintStraem where output have to be redirected
*/
public synchronized void printProcessErrorOutput(PrintStream printTo) {
if (stderr != null && stderr.length() > 0) {
printTo.println("========= Child VM System.err ========");
printTo.print(stderr);
printTo.println("======================================");
}
}
示例11: linkStreams
import java.io.PrintStream; //導入方法依賴的package包/類
private void linkStreams(final String version, final int vmNum, final ProcessHolder holder,
final InputStream in, final PrintStream out) {
Thread ioTransport = new Thread() {
public void run() {
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String vmName = "[" + VM.getVMName(version, vmNum) + "] ";
try {
String line = reader.readLine();
while (line != null) {
if (line.length() == 0) {
out.println();
} else {
out.print(vmName);
out.println(line);
}
line = reader.readLine();
}
} catch (Exception e) {
if (!holder.isKilled()) {
out.println("Error transporting IO from child process");
e.printStackTrace(out);
}
}
}
};
ioTransport.setDaemon(true);
ioTransport.start();
}
示例12: writeOn
import java.io.PrintStream; //導入方法依賴的package包/類
public static void writeOn(String message, PrintStream out) {
String newMesssage = converter.MessageConverter.toUpperCase(message);
if (!newMesssage.equals(message.toUpperCase(Locale.ROOT)))
throw new RuntimeException("Expected " + message.toUpperCase(Locale.ROOT)
+ ", got " + newMesssage );
out.println(newMesssage);
}
示例13: FileCopyWithOverwrite
import java.io.PrintStream; //導入方法依賴的package包/類
public void FileCopyWithOverwrite() throws IOException, StfException {
String FILE_1_CONTENTS = "filecopy1";
String FILE_2_CONTENTS = "filecopy2";
Path tempDir = getTemporaryDirectory();
// Create a file
Path newFilename1 = Paths.get("filecopy1.txt");
Path newFile1 = tempDir.resolve(newFilename1);
Files.createFile(newFile1);
assertTrue("File was not created", Files.exists(newFile1));
// Create a second file
Path newFilename2 = Paths.get("filecopy2.txt");
Path newFile2 = tempDir.resolve(newFilename2);
Files.createFile(newFile2);
assertTrue("File was not created", Files.exists(newFile2));
// Write something to file1 and file2 so that we can check the operation succeeded
PrintStream printStream1 = new PrintStream(Files.newOutputStream(newFile1,StandardOpenOption.WRITE));
printStream1.println(FILE_1_CONTENTS);
printStream1.close();
PrintStream printStream2 = new PrintStream(Files.newOutputStream(newFile2,StandardOpenOption.WRITE));
printStream2.println(FILE_2_CONTENTS);
printStream2.close();
Files.copy(newFile1,newFile2, StandardCopyOption.REPLACE_EXISTING);
InputStreamReader input = new InputStreamReader(Files.newInputStream(newFile2, StandardOpenOption.READ));
BufferedReader bufferedInput = new BufferedReader(input);
String contents = bufferedInput.readLine();
assertEquals("File contents of the overwritten file did not match the source", FILE_1_CONTENTS, contents);
bufferedInput.close();
okForCleanup();
}
示例14: create
import java.io.PrintStream; //導入方法依賴的package包/類
public ExecutionEventNode create(final EventContext ec) {
final PrintStream out = new PrintStream(env.out());
return new ExecutionEventNode() {
/*@Override
protected void onReturnValue(VirtualFrame frame, Object result) {
out.println("return" + this);
}*/
@Override
protected void onEnter(VirtualFrame frame) {
Node node = ec.getInstrumentedNode();
out.println("node: " + node);
out.println("-> " + node.getEncapsulatingSourceSection().toString());
// if (node instanceof InvokeNode) {
// InvokeNode invokeNode = (InvokeNode) node;
// out.println("invoke: " + invokeNode.getForm());
// } else if (node instanceof EvalFactory.EvalNodeGen) {
// EvalFactory.EvalNodeGen evalNode = (EvalFactory.EvalNodeGen) node;
// out.println("eval: " + evalNode);
// } else if (node instanceof RootNode) {
// RootNode rootNode = (RootNode) node;
// out.println("root: " + rootNode);
// }
}
};
}
示例15: exportAsXML
import java.io.PrintStream; //導入方法依賴的package包/類
/**
* Write all recorded event information, in XML format, to the given
* <code>PrintStream</code>. In addition, it is transformed by the given
* XSLT script.
*
* @param style
* @param out
* @throws javax.xml.parsers.ParserConfigurationException
* @throws javax.xml.transform.TransformerConfigurationException
* @throws javax.xml.transform.TransformerException
*/
public void exportAsXML(Document style, PrintStream out)
throws ParserConfigurationException, TransformerConfigurationException,
TransformerException {
Document doc = getDocumentBuilder().getDOMImplementation().createDocument(null, TN_ROOT_ELEMENT, null);
Element root = doc.getDocumentElement();
// Construct the DOM contents by scanning through all EventLists,
// and for each event adding everything to the DOM.
for (EventList eventList : eventLists) {
Element evlistElement = doc.createElement(TN_EVENT_LIST);
root.appendChild(evlistElement);
evlistElement.setAttribute(ATTR_START, Long.toString(eventList.getStartMillis()));
evlistElement.setAttribute(ATTR_NAME, eventList.getName());
//don't log repeated events
Tuple previous = new Tuple(0, "", 0, 0);
// For each Event
for (Tuple t : Collections.unmodifiableList(eventList)) {
// log only if it isn't the same
if (t != null && !t.equals(previous)) {
Element eventElement = doc.createElement(TN_EVENT);
evlistElement.appendChild(eventElement);
eventElement.setAttribute(ATTR_TYPE, t.getCodeName());
eventElement.setAttribute(ATTR_NAME, getShortenName(t.getName()));
eventElement.setAttribute(ATTR_TIME, getTimeMillisForLog(t));
eventElement.setAttribute(ATTR_TIME_DIFF_START, Long.toString(t.getTimeDifference()));
if (t.getMeasured()) {
eventElement.setAttribute(ATTR_MEASURED, "true");
}
}
previous = t;
}
}
// Now, transform it out
Transformer tr = style != null
? getTransformerFactory().newTransformer(new DOMSource(style))
: getTransformerFactory().newTransformer();
tr.setOutputProperty(OutputKeys.INDENT, "yes");
tr.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
DOMSource docSrc = new DOMSource(doc);
StreamResult rslt = new StreamResult(out);
out.println("<?xml version=\"1.0\" ?>");
out.println("<?xml-stylesheet type=\"text/xsl\" href=\"" + getPathToXsl() + "\" media=\"screen\"?>");
tr.transform(docSrc, rslt);
}