當前位置: 首頁>>代碼示例>>Java>>正文


Java PrintStream.flush方法代碼示例

本文整理匯總了Java中java.io.PrintStream.flush方法的典型用法代碼示例。如果您正苦於以下問題:Java PrintStream.flush方法的具體用法?Java PrintStream.flush怎麽用?Java PrintStream.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.PrintStream的用法示例。


在下文中一共展示了PrintStream.flush方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toString

import java.io.PrintStream; //導入方法依賴的package包/類
@Override
public String toString() {
  ByteArrayOutputStream baos = new ByteArrayOutputStream(64 * 1024);
  PrintStream ps = new PrintStream(baos);
  ps.print(this.getMessage());
  ps.print(" rc=");
  ps.print(this.rc);
  if (this.useCount > 0) {
    ps.print(" useCount=");
    ps.print(this.useCount);
  }
  ps.print(" by ");
  ps.print(this.threadName);
  if (this.owner != null) {
    ps.print(" owner=");
    ps.print(this.owner.getClass().getName());
    ps.print("@");
    ps.print(System.identityHashCode(this.owner));
  }

  ps.println(": ");
  cleanStackTrace(ps);
  ps.flush();

  return baos.toString();
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:27,代碼來源:RefCountChangeInfo.java

示例2: testJarExtract

import java.io.PrintStream; //導入方法依賴的package包/類
private static void testJarExtract(String jarFile) throws IOException {
    List<String> argList = new ArrayList<String>();
    argList.add("-xvf");
    argList.add(jarFile);
    argList.add(JARBACKSLASH + File.separatorChar + DIR + File.separatorChar + FILENAME);

    String jarArgs[] = new String[argList.size()];
    jarArgs = argList.toArray(jarArgs);

    PipedOutputStream pipedOutput = new PipedOutputStream();
    PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
    PrintStream out = new PrintStream(pipedOutput);

    int rc = JAR_TOOL.run(out, System.err, jarArgs);
    if (rc != 0) {
        fail("Could not list jar file.");
    }

    out.flush();
    check(pipedInput.available() > 0);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:22,代碼來源:JarBackSlash.java

示例3: validateSnapshot

import java.io.PrintStream; //導入方法依賴的package包/類
private void validateSnapshot(boolean expectSuccess) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    PrintStream original = System.out;
    try {
        System.setOut(ps);
        String args[] = new String[] { TESTNONCE, "--dir", TMPDIR };
        SnapshotVerifier.main(args);
        ps.flush();
        String reportString = baos.toString("UTF-8");

        System.err.println("Validate Snapshot :"+reportString);

        if (expectSuccess) {
            assertTrue(reportString.startsWith("Snapshot valid\n"));
            System.err.println("Validate Snapshot :" + "Snapshot valid");
        } else {
            assertTrue(reportString.startsWith("Snapshot corrupted\n"));
            System.err.println("Validate Snapshot :" + "Snapshot corrupted");
        }
    } catch (UnsupportedEncodingException e) {
    } finally {
        System.setOut(original);
    }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:26,代碼來源:TestSnapshotSave.java

示例4: main

import java.io.PrintStream; //導入方法依賴的package包/類
/** test code
    @param args command line
*/
public static void main(String[] args) {
  Logger logger = Logger.getLogger("edu.mines.jtk.util");
  PrintStream psInfo = new LoggerStream(logger, Level.INFO);
  //PrintStream psWarning = new LoggerStream(logger, Level.WARNING);
  psInfo.print(3.);
  psInfo.println("*3.=9.");
  //if (false) {
  //  psWarning.print(3.);
  //  psWarning.println("*3.=9.");
  //}
  psInfo.print(3.);
  psInfo.flush();
  psInfo.println("*3.=9.");
  psInfo.println();
  psInfo.print("x");
  psInfo.close();
}
 
開發者ID:MinesJTK,項目名稱:jtk,代碼行數:21,代碼來源:LoggerStream.java

示例5: dumpResolutions

import java.io.PrintStream; //導入方法依賴的package包/類
/**
 * USes its defined logger to generate a resolution report.
 *
 * @param loadPlan The loadplan that was processed.
 */
public void dumpResolutions(LoadPlan loadPlan) {
	if ( log.isDebugEnabled() ) {
		final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		final PrintStream printStream = new PrintStream( byteArrayOutputStream );
		final PrintWriter printWriter = new PrintWriter( printStream );

		printWriter.println( "LoadPlan QuerySpace resolutions" );

		for ( QuerySpace querySpace : loadPlan.getQuerySpaces().getRootQuerySpaces() ) {
			dumpQuerySpace( querySpace, 1, printWriter );
		}

		printWriter.flush();
		printStream.flush();

		log.debug( new String( byteArrayOutputStream.toByteArray() ) );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:24,代碼來源:AliasResolutionContextImpl.java

示例6: testJarList

import java.io.PrintStream; //導入方法依賴的package包/類
private static void testJarList(String jarFile) throws IOException {
    List<String> argList = new ArrayList<String>();
    argList.add("-tvf");
    argList.add(jarFile);
    argList.add(JARBACKSLASH + File.separatorChar + DIR + File.separatorChar + FILENAME);

    String jarArgs[] = new String[argList.size()];
    jarArgs = argList.toArray(jarArgs);

    PipedOutputStream pipedOutput = new PipedOutputStream();
    PipedInputStream pipedInput = new PipedInputStream(pipedOutput);
    PrintStream out = new PrintStream(pipedOutput);

    Main jarTool = new Main(out, System.err, "jar");
    if (!jarTool.run(jarArgs)) {
        fail("Could not list jar file.");
    }

    out.flush();
    check(pipedInput.available() > 0);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:22,代碼來源:JarBackSlash.java

示例7: printScoresHapler

import java.io.PrintStream; //導入方法依賴的package包/類
public void printScoresHapler(List<Fragment> fragments, PrintStream out) {
	for(Fragment f:fragments) {
		out.println(""+f.getFirstPos()+" "+f.getLastPos());
		for(int i=0;i<f.length();i++) {
			out.print(" "+(1-errorRate)+" ");
		}
		out.println();
	}
	out.flush();
}
 
開發者ID:ShujiaHuang,項目名稱:RefHap,代碼行數:11,代碼來源:Simulator.java

示例8: printThreadInfo

import java.io.PrintStream; //導入方法依賴的package包/類
/**
 * Print all of the thread's information and stack traces.
 * 
 * @param stream the stream to
 * @param title a string title for the stack trace
 */
public synchronized static void printThreadInfo(PrintStream stream,
                                   String title) {
  final 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, STACK_DEPTH);
    if (info == null) {
      stream.println("  Inactive");
      continue;
    }
    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();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:46,代碼來源:ReflectionUtils.java

示例9: printHaplotype

import java.io.PrintStream; //導入方法依賴的package包/類
private void printHaplotype(List<Integer> variantPositions,String outputHaplotype, PrintStream out) {
	for(int i=0;i<variantPositions.size();i++) {
		char call = outputHaplotype.charAt(i);
		char call2 = call;
		if(call == Fragment.ALLELE1CHAR) call2 = Fragment.ALLELE2CHAR;
		else if (call == Fragment.ALLELE2CHAR) call2 = Fragment.ALLELE1CHAR;
		out.println(""+variantPositions.get(i)+"\t"+call+"\t"+call2);
	}
	out.flush();
	out.close();
}
 
開發者ID:ShujiaHuang,項目名稱:RefHap,代碼行數:12,代碼來源:PhasingStatisticsCalculator.java

示例10: generateSignatureFile

import java.io.PrintStream; //導入方法依賴的package包/類
/**
 * Write the signature file to the given output stream.
 */
private void generateSignatureFile(Manifest manifest, OutputStream out)
        throws IOException, GeneralSecurityException {
    out.write(("Signature-Version: 1.0\r\n").getBytes());
    out.write(("Created-By: 1.0 (Android SignApk)\r\n").getBytes());


    // BASE64Encoder base64 = new BASE64Encoder();
    MessageDigest md = MessageDigest.getInstance("SHA1");
    PrintStream print = new PrintStream(
            new DigestOutputStream(new ByteArrayOutputStream(), md),
            true, "UTF-8");

    // Digest of the entire manifest
    manifest.write(print);
    print.flush();

    out.write(("SHA1-Digest-Manifest: " + Base64.encode(md.digest()) + "\r\n\r\n").getBytes());

    Map<String, Attributes> entries = manifest.getEntries();
    for (Map.Entry<String, Attributes> entry : entries.entrySet()) {
        if (canceled) break;
        progressHelper.progress(ProgressEvent.PRORITY_NORMAL, resourceAdapter.getString(ResourceAdapter.Item.GENERATING_SIGNATURE_FILE));
        // Digest of the manifest stanza for this entry.
        String nameEntry = "Name: " + entry.getKey() + "\r\n";
        print.print(nameEntry);
        for (Map.Entry<Object, Object> att : entry.getValue().entrySet()) {
            print.print(att.getKey() + ": " + att.getValue() + "\r\n");
        }
        print.print("\r\n");
        print.flush();

        out.write(nameEntry.getBytes());
        out.write(("SHA1-Digest: " + Base64.encode(md.digest()) + "\r\n\r\n").getBytes());
    }

}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:40,代碼來源:ZipSigner.java

示例11: createOkResponse

import java.io.PrintStream; //導入方法依賴的package包/類
private void createOkResponse(PrintStream output, byte[] bytes) throws IOException {
    // formatting response
    output.println("HTTP/1.0 200 OK");
    output.println("Content-Type: text/html");
    output.println("Content-Length: " + bytes.length);
    output.println();
    output.write(bytes);
    output.flush();
}
 
開發者ID:mipegir,項目名稱:RemoteLogcatLibrary,代碼行數:10,代碼來源:RemoteLogCatServer.java

示例12: startLocator

import java.io.PrintStream; //導入方法依賴的package包/類
protected static void startLocator(final String name, int port, final Properties extraProps,
    final Properties javaProps, final String[] expectedExceptions) {
  try {
    Properties authProps = new Properties();

    if (extraProps != null) {
      authProps.putAll(extraProps);
    }
    authProps.setProperty(MCAST_PORT, "0");
    authProps.setProperty(LOCATORS, getIPLiteral() + "[" + port + "]");
    authProps.setProperty(ENABLE_CLUSTER_CONFIGURATION, "false");

    clearStaticSSLContext();

    setJavaProps(javaProps);

    File logFile = new File(name + "-locator" + port + ".log");
    FileOutputStream logOut = new FileOutputStream(logFile);
    PrintStream logStream = new PrintStream(logOut);
    addIgnoredExceptions(expectedExceptions);
    logStream.flush();

    locator = Locator.startLocatorAndDS(port, logFile, null, authProps);

  } catch (IOException ex) {
    fail("While starting locator on port " + port, ex);
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:29,代碼來源:SecurityTestUtils.java

示例13: asString

import java.io.PrintStream; //導入方法依賴的package包/類
public String asString(Return rootReturn, int depth) {
	final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
	final PrintStream ps = new PrintStream( byteArrayOutputStream );
	write( rootReturn,  depth, ps );
	ps.flush();
	return new String( byteArrayOutputStream.toByteArray() );

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:ReturnGraphTreePrinter.java

示例14: dump

import java.io.PrintStream; //導入方法依賴的package包/類
public void dump(PrintStream out) {
    int width = 100;
    out.println(StringUtil.header(this.getClass().getSimpleName(), "=", width));
    for (String log : this.getLogMessages()) {
        out.println(log.trim());
    }
    out.println(StringUtil.repeat("=", width));
    out.flush();
}
 
開發者ID:s-store,項目名稱:s-store,代碼行數:10,代碼來源:RingBufferAppender.java

示例15: testInstantiateAllInstances

import java.io.PrintStream; //導入方法依賴的package包/類
public void testInstantiateAllInstances () {
    List<String> errors = new ArrayList<String>();
    
    Enumeration<? extends FileObject> files = FileUtil.getConfigRoot().getChildren(true);
    while (files.hasMoreElements()) {
        FileObject fo = files.nextElement();
        
        if (skipFile(fo)) {
            continue;
        }
        
        try {
            DataObject obj = DataObject.find (fo);
            InstanceCookie ic = obj.getLookup().lookup(InstanceCookie.class);
            if (ic != null) {
                Object o = ic.instanceCreate ();
                if (fo.getPath().matches("Services/.+[.]instance")) {
                    String instanceOf = (String) fo.getAttribute("instanceOf");
                    if (instanceOf == null) {
                        errors.add("File " + fo.getPath() + " should declare instanceOf");
                    } else if (o != null) {
                        for (String piece : instanceOf.split(", ?")) {
                            if (!Class.forName(piece, true, Lookup.getDefault().lookup(ClassLoader.class)).isInstance(o)) {
                                errors.add("File " + fo.getPath() + " claims to be a " + piece + " but is not (instance of " + o.getClass() + ")");
                            }
                        }
                    }
                } else if (fo.getPath().matches("Services/.+[.]settings")) {
                    if (!fo.asText().contains("<instanceof")) {
                        errors.add("File " + fo.getPath() + " should declare <instanceof class=\"...\"/>");
                    }
                    // XXX test assignability here too, perhaps (but only used in legacy code)
                }
            }
        } catch (Exception ex) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintStream ps = new PrintStream(baos);
            ex.printStackTrace(ps);
            ps.flush();
            errors.add(
                "File " + fo.getPath() +
                "\nRead from: " + Arrays.toString((Object[])fo.getAttribute("layers")) +
                "\nthrew: " + baos);
        }
    }
    
    assertNoErrors("Some instances cannot be created", errors);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:49,代碼來源:ValidateLayerConsistencyTest.java


注:本文中的java.io.PrintStream.flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。