Java Code Examples for java.io.PrintStream

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project apb, under directory /modules/test-tasks/src/apb/tests/tasks/.

Source file: ExecTest.java

  20 
vote

static String invokeExec(String cmd,String... args){
  ByteArrayOutputStream b=new ByteArrayOutputStream();
  PrintStream prev=System.out;
  try {
    PrintStream p=new PrintStream(b);
    System.setOut(p);
    exec(cmd,args).execute();
    p.close();
  }
  finally {
    System.setOut(prev);
  }
  return b.toString();
}
 

Example 2

From project any23, under directory /core/src/main/java/org/apache/any23/validator/.

Source file: XMLValidationReportSerializer.java

  19 
vote

public void serialize(ValidationReport vr,OutputStream os) throws SerializationException {
  final PrintStream ps=new PrintStream(os);
  try {
    serializeObject(vr,ps);
  }
  finally {
    ps.flush();
  }
}
 

Example 3

From project chililog-server, under directory /src/main/java/org/chililog/server/common/.

Source file: ChiliLogException.java

  19 
vote

/** 
 * @return The stack trace as a string
 */
public String getStackTraceAsString(){
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    PrintStream ps=new PrintStream(baos,true,"UTF-8");
    this.printStackTrace(ps);
    return baos.toString("UTF-8");
  }
 catch (  Exception ex) {
    return this.toString();
  }
}
 

Example 4

From project aviator, under directory /src/main/java/com/googlecode/aviator/runtime/function/system/.

Source file: PrintFunction.java

  18 
vote

@Override public AviatorObject call(Map<String,Object> env,AviatorObject arg1,AviatorObject arg2){
  OutputStream out=(OutputStream)FunctionUtils.getJavaObject(arg1,env);
  PrintStream printStream=new PrintStream(out);
  printStream.print(arg2.getValue(env));
  return AviatorNil.NIL;
}
 

Example 5

From project avro, under directory /lang/java/mapred/src/test/java/org/apache/avro/mapred/.

Source file: WordCountUtil.java

  18 
vote

public static void writeLinesTextFile() throws IOException {
  FileUtil.fullyDelete(DIR);
  LINES_FILE.getParentFile().mkdirs();
  PrintStream out=new PrintStream(LINES_TEXT_FILE);
  for (  String line : LINES)   out.println(line);
  out.close();
}
 

Example 6

From project bndtools, under directory /bndtools.jareditor/src/bndtools/jareditor/internal/.

Source file: JARPrintPage.java

  18 
vote

private static String print(File file) throws Exception {
  ByteArrayOutputStream bos=new ByteArrayOutputStream();
  PrintStream ps=new PrintStream(bos,false,"UTF-8");
  Printer printer=new Printer();
  printer.setOut(ps);
  int options=255;
  printer.doPrint(file.getAbsolutePath(),options);
  ps.close();
  return new String(bos.toByteArray(),"UTF-8");
}
 

Example 7

From project camel-osgi, under directory /tests/src/test/java/org/apache/camel/osgi/service/itest/.

Source file: OsgiIntegrationTest.java

  18 
vote

/** 
 * Executes the command and returns the output as a String.
 * @param command the command to execute
 * @return result of command execution
 */
protected String executeCommand(String command) throws Exception {
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  PrintStream printStream=new PrintStream(byteArrayOutputStream);
  CommandSession commandSession=commandProcessor.createSession(System.in,printStream,System.err);
  commandSession.put("APPLICATION",System.getProperty("karaf.name","root"));
  commandSession.put("USER","karaf");
  commandSession.execute(command);
  return byteArrayOutputStream.toString();
}
 

Example 8

From project candlepin, under directory /src/test/java/org/candlepin/exceptions/mappers/.

Source file: RuntimeExceptionMapperTest.java

  18 
vote

@Before public void setUp() throws IOException, URISyntaxException {
  PrintStream ps=new PrintStream(new File(this.getClass().getClassLoader().getResource("candlepin_info.properties").toURI()));
  ps.println("version=${version}");
  ps.println("release=${release}");
  ps.close();
}
 

Example 9

From project cascading, under directory /src/core/cascading/operation/.

Source file: Debug.java

  18 
vote

/** 
 * @see Filter#isRemove(cascading.flow.FlowProcess,FilterCall) 
 */
public boolean isRemove(FlowProcess flowProcess,FilterCall<Long> filterCall){
  PrintStream stream=output == Output.STDOUT ? System.out : System.err;
  if (printFields && filterCall.getContext() % printFieldsEvery == 0)   print(stream,filterCall.getArguments().getFields().print());
  if (filterCall.getContext() % printTupleEvery == 0)   print(stream,filterCall.getArguments().getTuple().print());
  filterCall.setContext(filterCall.getContext() + 1);
  return false;
}
 

Example 10

From project ChkBugReport, under directory /src/com/sonyericsson/chkbugreport/doc/.

Source file: Doc.java

  18 
vote

private void writeFrames(Chapter toc) throws FileNotFoundException {
  PrintStream ps=new PrintStream(mIndexHtml);
  Util.writeHTMLHeaderLite(ps,getFileName());
  String tocFn=toc.getAnchor().getFileName();
  String first=getChapter(0).getAnchor().getFileName();
  ps.println("<frameset cols=\"25%,75%\">");
  ps.println("  <frame name=\"toc\" src=\"data/" + tocFn + "\"/>");
  ps.println("  <frame name=\"content\" src=\"data/" + first + "\"/>");
  ps.println("</frameset>");
  Util.writeHTMLFooterLite(ps);
  ps.close();
}
 

Example 11

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/datacollection/collector/servlet/.

Source file: CommitCheckServlet.java

  18 
vote

@Override protected void doGet(HttpServletRequest req,HttpServletResponse resp) throws ServletException, IOException {
  PrintStream out=new PrintStream(resp.getOutputStream());
  resp.setStatus(200);
  out.println("<html><body><h2>Commit status</h2><ul>");
  for (  String s : commitCheck.getLengthList())   out.println("<li>" + s + "</li>");
  out.println("</ul></body></html>");
}
 

Example 12

From project CIShell, under directory /testing/org.cishell.utilities.tests/src/org/cishell/utilities/logging/.

Source file: PrintStreamLoggerTest.java

  18 
vote

@Test public void createNullPrintStreamLogger(){
  PrintStream ps=null;
  try {
    PrintStreamLogger l=new PrintStreamLogger(ps);
    fail("Null did not throw an exception for the PrintStream");
  }
 catch (  NullPointerException e) {
  }
}
 

Example 13

From project activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/.

Source file: CacheEventListenerTest.java

  17 
vote

@Test public void shouldNotBreakIfListenerThrowsException() throws IOException {
class BadEventListener implements CacheEventListener {
    public void onFlush(    CacheEvent event){
      throw new RuntimeException("I'm a bad, baaad listener....");
    }
  }
  BadEventListener listener=new BadEventListener();
  Registry.cacheManager().addCacheEventListener(listener);
  PrintStream errOrig=System.err;
  ByteArrayOutputStream bout=new ByteArrayOutputStream();
  PrintStream err=new PrintStream(bout);
  System.setErr(err);
  Person.createIt("name","Matt","last_name","Diamont","dob","1962-01-01");
  err.flush();
  bout.flush();
  String exception=bout.toString();
  a(exception.contains(" I'm a bad, baaad listener")).shouldBeTrue();
  System.setErr(errOrig);
}
 

Example 14

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: GUIFactory.java

  17 
vote

public static void suppressErrors(boolean suppress){
  if (suppress) {
    System.setErr(new PrintStream(new OutputStream(){
      public void write(      int b){
      }
    }
));
  }
 else {
    System.setErr(s_errorStream);
  }
}
 

Example 15

From project adt-cdt, under directory /com.android.ide.eclipse.adt.cdt/src/com/android/ide/eclipse/adt/cdt/internal/discovery/.

Source file: NDKDiscoveredPathInfo.java

  17 
vote

private void save(){
  try {
    File infoFile=getInfoFile();
    infoFile.getParentFile().mkdirs();
    PrintStream out=new PrintStream(infoFile);
    out.print("t,");
    out.print(lastUpdate);
    out.println();
    for (    IPath include : includePaths) {
      out.print("i,");
      out.print(include.toPortableString());
      out.println();
    }
    for (    Entry<String,String> symbol : symbols.entrySet()) {
      out.print("d,");
      out.print(symbol.getKey());
      out.print(",");
      out.print(symbol.getValue());
      out.println();
    }
    out.close();
  }
 catch (  IOException e) {
    Activator.log(e);
  }
}
 

Example 16

From project airlift, under directory /configuration/src/test/java/io/airlift/configuration/.

Source file: TestConfigurationLoader.java

  17 
vote

@Test public void testLoadsFromFile() throws IOException {
  final File file=File.createTempFile("config",".properties",tempDir);
  PrintStream out=new PrintStream(new FileOutputStream(file));
  try {
    out.print("test: foo");
  }
 catch (  Exception e) {
    out.close();
  }
  System.setProperty("config",file.getAbsolutePath());
  ConfigurationLoader loader=new ConfigurationLoader();
  Map<String,String> properties=loader.loadProperties();
  assertEquals(properties.get("test"),"foo");
  assertEquals(properties.get("config"),file.getAbsolutePath());
  System.getProperties().remove("config");
}
 

Example 17

From project almira-sample, under directory /almira-sample-client/src/test/java/almira/sample/client/.

Source file: ListCatapultTest.java

  17 
vote

@Test public void executesQueryWithoutErrors(){
  context.checking(new Expectations(){
{
      oneOf(queryService).findAll(0,MAX_RECORDS);
      will(returnValue(RESULT_LIST));
    }
  }
);
  PrintStream sysOut=System.out;
  try {
    ByteArrayOutputStream baos=new ByteArrayOutputStream();
    System.setOut(new PrintStream(baos));
    ListCatapults.executeQuery(queryService);
    Assert.assertTrue("Output contains Catapult name",baos.toString().contains(CATAPULT_NAME));
  }
  finally {
    System.setOut(sysOut);
  }
}
 

Example 18

From project android_build, under directory /tools/droiddoc/src/.

Source file: Stubs.java

  17 
vote

static void writeClassFile(String stubsDir,ClassInfo cl){
  if (cl.containingClass() != null) {
    return;
  }
  if (cl.containingPackage() != null && cl.containingPackage().name().equals("")) {
    return;
  }
  String filename=stubsDir + '/' + javaFileName(cl);
  File file=new File(filename);
  ClearPage.ensureDirectory(file);
  PrintStream stream=null;
  try {
    stream=new PrintStream(file);
    writeClassFile(stream,cl);
  }
 catch (  FileNotFoundException e) {
    System.err.println("error writing file: " + filename);
  }
 finally {
    if (stream != null) {
      stream.close();
    }
  }
}
 

Example 19

From project anode, under directory /bridge-stub-generator/src/org/meshpoint/anode/stub/.

Source file: StubGenerator.java

  17 
vote

/** 
 * Create a ClassWriter instance for the specified stub class
 * @param className class name, without package component
 * @param mode stub mode
 * @throws IOException
 */
public ClassWriter(String className,int mode) throws IOException {
  String stubPackage=StubUtil.getStubPackage(mode).replace('.','/');
  File packageDir=new File(destination.toString() + '/' + stubPackage);
  packageDir.mkdirs();
  if (!packageDir.exists())   throw new IOException("Unable to create package directory (" + packageDir.toString() + ")");
  String classFilename=className + ".java";
  File classFile=new File(packageDir,classFilename);
  FileOutputStream fos=new FileOutputStream(classFile);
  this.ps=new PrintStream(fos);
}
 

Example 20

From project ant4eclipse, under directory /org.ant4eclipse.ant.jdt/src/org/ant4eclipse/ant/jdt/ecj/.

Source file: JavacCompilerAdapter.java

  17 
vote

/** 
 * Enables the capturing so we can analyze the outcome of the java compiler.
 */
private void startCapturing(){
  this._stdout=System.out;
  this._stderr=System.err;
  this._byteout.reset();
  System.setErr(new PrintStream(this._byteout));
  System.setOut(new PrintStream(this._byteout));
}
 

Example 21

From project bdd-security, under directory /src/main/java/net/continuumsecurity/.

Source file: Config.java

  17 
vote

public static synchronized void writeTable(String file,List<List<String>> table){
  PrintStream writer=null;
  System.out.println("Writing to table file: " + file);
  try {
    writer=new PrintStream(new FileOutputStream(file,false));
    for (    List<String> row : table) {
      StringBuilder sb=new StringBuilder();
      for (      String col : row) {
        sb.append("|").append(col).append("\t\t");
      }
      writer.println(sb.toString());
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
 finally {
    writer.close();
  }
}
 

Example 22

From project big-data-plugin, under directory /test-src/org/pentaho/di/job/entries/sqoop/.

Source file: SqoopImportJobEntryTest.java

  17 
vote

@Test public void attachAndRemoveLoggingAppenders(){
  SqoopImportJobEntry je=new SqoopImportJobEntry();
  PrintStream stderr=System.err;
  Logger sqoopLogger=JobEntryUtils.findLogger("org.apache.sqoop");
  Logger hadoopLogger=JobEntryUtils.findLogger("org.apache.hadoop");
  assertFalse(sqoopLogger.getAllAppenders().hasMoreElements());
  assertFalse(hadoopLogger.getAllAppenders().hasMoreElements());
  try {
    je.attachLoggingAppenders();
    assertTrue(sqoopLogger.getAllAppenders().hasMoreElements());
    assertTrue(hadoopLogger.getAllAppenders().hasMoreElements());
    assertEquals(LoggingProxy.class,System.err.getClass());
    je.removeLoggingAppenders();
    assertFalse(sqoopLogger.getAllAppenders().hasMoreElements());
    assertFalse(hadoopLogger.getAllAppenders().hasMoreElements());
    assertEquals(stderr,System.err);
  }
  finally {
    System.setErr(stderr);
    sqoopLogger.removeAllAppenders();
    hadoopLogger.removeAllAppenders();
  }
}
 

Example 23

From project BlameSubversion-plugin, under directory /src/main/java/hudson/scm/.

Source file: BlameSubversionChangeLogBuilder.java

  17 
vote

private boolean buildModule(String url,SVNLogClient svnlc,SVNXMLLogHandler logHandler) throws IOException2 {
  PrintStream logger=listener.getLogger();
  Long prevRev=previousRevisions.get(url);
  if (prevRev == null) {
    logger.println("no revision recorded for " + url + " in the previous build");
    return false;
  }
  Long thisRev=thisRevisions.get(url);
  if (thisRev == null) {
    listener.error("No revision found for URL: " + url + " in "+ BlameSubversionSCM.getRevisionFile(build)+ ". Revision file contains: "+ thisRevisions.keySet());
    return false;
  }
  if (thisRev.equals(prevRev)) {
    logger.println("no change for " + url + " since the previous build");
    return false;
  }
  try {
    if (debug)     listener.getLogger().printf("Computing changelog of %1s from %2s to %3s\n",SVNURL.parseURIEncoded(url),prevRev + 1,thisRev);
    svnlc.doLog(SVNURL.parseURIEncoded(url),null,SVNRevision.UNDEFINED,SVNRevision.create(prevRev + 1),SVNRevision.create(thisRev),false,true,0,debug ? new DebugSVNLogHandler(logHandler) : logHandler);
    if (debug)     listener.getLogger().println("done");
  }
 catch (  SVNException e) {
    throw new IOException2("revision check failed on " + url,e);
  }
  return true;
}
 

Example 24

From project BombusLime, under directory /src/org/bombusim/lime/activity/.

Source file: LoggerActivity.java

  17 
vote

private void saveLog(){
  String state=Environment.getExternalStorageState();
  if (!Environment.MEDIA_MOUNTED.equals(state)) {
    Toast.makeText(this,R.string.cantWriteStorage,Toast.LENGTH_LONG).show();
    return;
  }
  File externalRoot=Environment.getExternalStorageDirectory();
  Time tf=new Time(Time.getCurrentTimezone());
  tf.set(System.currentTimeMillis());
  String fn="BombusLime_" + tf.format2445() + ".txt";
  File log=new File(externalRoot,fn);
  ArrayList<LoggerEvent> events=Lime.getInstance().getLog().getLogRecords();
  try {
    PrintStream ps=new PrintStream(log);
    for (    LoggerEvent event : events) {
      ps.print(event.eventTypeName());
      ps.print(' ');
      tf.set(event.timestamp);
      ps.print(tf.format3339(false));
      ps.print(' ');
      ps.println(event.title);
      if (event.message != null) {
        ps.println(event.message);
        ps.println();
      }
    }
    ps.close();
  }
 catch (  FileNotFoundException e) {
    Toast.makeText(this,R.string.cantWriteStorage,Toast.LENGTH_LONG).show();
    e.printStackTrace();
    return;
  }
  Toast.makeText(this,"Log saved to " + externalRoot.getAbsolutePath() + '/'+ fn,Toast.LENGTH_LONG).show();
}
 

Example 25

From project C-Cat, under directory /core/src/main/java/gov/llnl/ontology/mapreduce/stats/.

Source file: WordnetShortestPathMR.java

  17 
vote

/** 
 * {@inheritDoc}
 */
public int run(String[] args) throws Exception {
  ArgOptions options=new ArgOptions();
  options.addOption('w',"wordnetDir","The directory path to the wordnet data files",true,"PATH","Required");
  options.parseOptions(args);
  if (!options.hasOption('w')) {
    System.err.println("usage: java WordnetShortestPathMR [OPTIONS] <outdir>\n" + options.prettyPrint());
  }
  OntologyReader reader=WordNetCorpusReader.initialize(options.getStringOption('w'));
  Set<Synset> synsetSet=new HashSet<Synset>();
  for (  String lemma : reader.wordnetTerms())   for (  Synset synset : reader.getSynsets(lemma))   synsetSet.add(synset);
  Synset[] synsets=synsetSet.toArray(new Synset[0]);
  PrintStream outStream=createPrintStream();
  for (int i=0; i < synsets.length; ++i)   for (int j=i + 1; j < synsets.length; ++j)   outStream.printf("%s|%s\n",synsets[i].getName(),synsets[j].getName());
  outStream.close();
  Configuration conf=getConf();
  conf.set(WORDNET,options.getStringOption('w'));
  Job job=new Job(conf,"Compute Wordnet Shortest Paths");
  job.setJarByClass(WordnetShortestPathMR.class);
  job.setMapperClass(WordnetShortestPathMapper.class);
  job.setInputFormatClass(LineDocInputFormat.class);
  FileInputFormat.addInputPath(job,new Path(TEMP_TERM_PAIR_PATH));
  job.setCombinerClass(Reducer.class);
  job.setReducerClass(Reducer.class);
  job.setOutputFormatClass(TextOutputFormat.class);
  TextOutputFormat.setOutputPath(job,new Path(options.getPositionalArg(0)));
  job.waitForCompletion(true);
  return 0;
}
 

Example 26

From project CBCJVM, under directory /cbc/CBCJVM/src/cbccore/low/simulator/.

Source file: SimulatedDisplay.java

  17 
vote

public SimulatedDisplay(CBCSimulator c){
  cbc=c;
  textBox=new JTextArea("On Simulator!\n");
  textBox.setLineWrap(true);
  out=new PrintStream(new TextAreaOutputStream(textBox,TextAreaOutputStream.DEFAULT_BUFFER_SIZE));
}
 

Example 27

From project clearcase-plugin, under directory /src/main/java/hudson/plugins/clearcase/action/.

Source file: SnapshotCheckoutAction.java

  17 
vote

protected SnapshotCheckoutAction.LoadRulesDelta getLoadRulesDelta(Set<String> configSpecLoadRules,Launcher launcher){
  Set<String> removedLoadRules=new LinkedHashSet<String>(configSpecLoadRules);
  Set<String> addedLoadRules=new LinkedHashSet<String>();
  if (!ArrayUtils.isEmpty(loadRules)) {
    for (    String loadRule : loadRules) {
      addedLoadRules.add(ConfigSpec.cleanLoadRule(loadRule,launcher.isUnix()));
    }
    removedLoadRules.removeAll(addedLoadRules);
    addedLoadRules.removeAll(configSpecLoadRules);
    PrintStream logger=launcher.getListener().getLogger();
    for (    String removedLoadRule : removedLoadRules) {
      logger.println("Removed load rule : " + removedLoadRule);
    }
    for (    String addedLoadRule : addedLoadRules) {
      logger.println("Added load rule : " + addedLoadRule);
    }
  }
  return new SnapshotCheckoutAction.LoadRulesDelta(removedLoadRules,addedLoadRules);
}
 

Example 28

From project awaitility, under directory /awaitility/src/test/java/com/jayway/awaitility/.

Source file: AwaitilityTest.java

  16 
vote

public AssertExceptionThrownInAnotherThreadButNeverCaughtByAnyThreadTest() throws Exception {
  ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream();
  System.setErr(new PrintStream(byteArrayOutputStream,true));
  try {
    testLogic();
  }
  finally {
    String errorMessage=byteArrayOutputStream.toString();
    try {
      assertTrue(errorMessage.contains("Illegal state!"));
    }
  finally {
      System.setErr(System.err);
    }
  }
}
 

Example 29

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: Utils.java

  15 
vote

public static void log(String message,PrintStream out){
  Date date=new Date();
  out.println("[" + date.toString() + "] "+ message);
  if (guireporter != null) {
    guireporter.setText("[" + date.toString() + "] "+ message+ "\n"+ guireporter.getText());
  }
}
 

Example 30

From project aether-ant, under directory /src/test/java/org/eclipse/aether/ant/.

Source file: AntBuildsTest.java

  15 
vote

@Override public void configureProject(String filename,int logLevel) throws BuildException {
  super.configureProject(filename,logLevel);
  DefaultLogger logger=new DefaultLogger(){
    @Override protected void printMessage(    String message,    PrintStream stream,    int priority){
      message=System.currentTimeMillis() + " " + message;
      super.printMessage(message,stream,priority);
    }
  }
;
  logger.setMessageOutputLevel(logLevel);
  logger.setOutputPrintStream(System.out);
  logger.setErrorPrintStream(System.err);
  getProject().addBuildListener(logger);
}
 

Example 31

From project AmDroid, under directory /AmDroid/src/main/java/com/jaeckel/amenoid/util/.

Source file: HelloWorldMaker.java

  15 
vote

/** 
 * Generates Dalvik bytecode equivalent to the following method. public static void hello() { int a = 0xabcd; int b = 0xaaaa; int c = a - b; String s = Integer.toHexString(c); System.out.println(s); return; }
 */
private static void generateHelloMethod(DexMaker dexMaker,TypeId<?> declaringType){
  TypeId<System> systemType=TypeId.get(System.class);
  TypeId<PrintStream> printStreamType=TypeId.get(PrintStream.class);
  MethodId hello=declaringType.getMethod(TypeId.VOID,"hello");
  Code code=dexMaker.declare(hello,Modifier.STATIC | Modifier.PUBLIC);
  Local<Integer> a=code.newLocal(TypeId.INT);
  Local<Integer> b=code.newLocal(TypeId.INT);
  Local<Integer> c=code.newLocal(TypeId.INT);
  Local<String> s=code.newLocal(TypeId.STRING);
  Local<PrintStream> localSystemOut=code.newLocal(printStreamType);
  code.loadConstant(a,0xabcd);
  code.loadConstant(b,0xaaaa);
  code.op(BinaryOp.SUBTRACT,c,a,b);
  MethodId<Integer,String> toHexString=TypeId.get(Integer.class).getMethod(TypeId.STRING,"toHexString",TypeId.INT);
  code.invokeStatic(toHexString,s,c);
  FieldId<System,PrintStream> systemOutField=systemType.getField(printStreamType,"out");
  code.sget(systemOutField,localSystemOut);
  MethodId<PrintStream,Void> printlnMethod=printStreamType.getMethod(TypeId.VOID,"println",TypeId.STRING);
  code.invokeVirtual(printlnMethod,null,localSystemOut,s);
  code.returnVoid();
}
 

Example 32

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/config/.

Source file: ConfigurationException.java

  15 
vote

/** 
 * Prints this <code>Throwable</code> and its backtrace to the specified print stream.
 * @param s   <code>PrintStream</code> to use for output
 */
public void printStackTrace(PrintStream s){
  super.printStackTrace(s);
  if (throwable != null) {
    s.println("with nested exception " + throwable);
    throwable.printStackTrace(s);
  }
}
 

Example 33

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/jsword/versification/.

Source file: BibleInfo.java

  15 
vote

/** 
 * This is the code used to create ORDINAL_AT_START_OF_CHAPTER and ORDINAL_AT_START_OF_BOOK. It is usually commented out because I don't see any point in making .class files bigger for no reason and this is needed only very rarely.
 */
public void optimize(PrintStream out) throws NoSuchVerseException {
  int count=0;
  int verseNum=1;
  out.println("    private static final short[] ORDINAL_AT_START_OF_BOOK =");
  out.println("    {");
  out.print("        ");
  for (  BibleBook b : EnumSet.range(BibleBook.GEN,BibleBook.REV)) {
    String vstr1="     " + verseNum;
    String vstr2=vstr1.substring(vstr1.length() - 5);
    out.print(vstr2 + ", ");
    verseNum+=versesInBook(b);
    if (++count % 10 == 0) {
      out.println();
      out.print("        ");
    }
  }
  out.println();
  out.println("    };");
  count=0;
  verseNum=1;
  out.println("    private static final short[][] ORDINAL_AT_START_OF_CHAPTER =");
  out.println("    {");
  for (  BibleBook b : EnumSet.range(BibleBook.GEN,BibleBook.REV)) {
    out.println("        { ");
    for (int c=1; c <= BibleInfo.chaptersInBook(b); c++) {
      String vstr1="     " + verseNum;
      String vstr2=vstr1.substring(vstr1.length() - 5);
      out.println(vstr2 + ", ");
      verseNum+=BibleInfo.versesInChapter(b,c);
    }
    out.println("},");
  }
  out.println("    };");
}
 

Example 34

From project android-database-sqlcipher, under directory /src/net/sqlcipher/.

Source file: DatabaseUtils.java

  15 
vote

/** 
 * Prints the contents of a Cursor to a PrintSteam. The position is restored after printing.
 * @param cursor the cursor to print
 * @param stream the stream to print to
 */
public static void dumpCursor(Cursor cursor,PrintStream stream){
  stream.println(">>>>> Dumping cursor " + cursor);
  if (cursor != null) {
    int startPos=cursor.getPosition();
    cursor.moveToPosition(-1);
    while (cursor.moveToNext()) {
      dumpCurrentRow(cursor,stream);
    }
    cursor.moveToPosition(startPos);
  }
  stream.println("<<<<<");
}
 

Example 35

From project Application-Builder, under directory /src/main/java/org/silverpeas/applicationbuilder/.

Source file: AppBuilderException.java

  15 
vote

public void printStackTrace(PrintStream s){
  if (nestedException != null) {
    s.println(getMessage());
    nestedException.printStackTrace(s);
  }
 else {
    super.printStackTrace(s);
  }
}
 

Example 36

From project archive-commons, under directory /archive-commons/src/main/java/org/archive/resource/.

Source file: AbstractResource.java

  15 
vote

public static void dump(PrintStream out,Resource resource) throws IOException {
  MetaData m=resource.getMetaData();
  out.println("Headers Before");
  out.print(m.toString());
  out.println("Resource Follows:\n===================");
  StreamCopy.copy(resource.getInputStream(),out);
  out.println("[\n]Headers After");
  out.print(m.toString());
}
 

Example 37

From project arquillian-container-gae, under directory /gae-remote/src/main/java/org/jboss/arquillian/container/appengine/remote/.

Source file: AppEngineRemoteContainer.java

  15 
vote

public PasswordOutputStream(ThreadGroup threads,PrintStream out,Runnable onExpected){
  this.threads=threads;
  this.out=out;
  this.onExpected=onExpected;
  try {
    this.expect="Password for".getBytes("ASCII");
  }
 catch (  UnsupportedEncodingException e) {
    throw new RuntimeException(e);
  }
}
 

Example 38

From project atlas, under directory /src/test/java/com/ning/atlas/.

Source file: TestLibraryBehaviors.java

  15 
vote

@Test public void testFoo() throws Exception {
  POSIX posix=POSIXFactory.getPOSIX(new POSIXHandler(){
    @Override public void error(    Errno errno,    String s){
    }
    @Override public void unimplementedError(    String s){
    }
    @Override public void warn(    WARNING_ID warning_id,    String s,    Object... objects){
    }
    @Override public boolean isVerbose(){
      return false;
    }
    @Override public File getCurrentWorkingDirectory(){
      return null;
    }
    @Override public String[] getEnv(){
      return new String[0];
    }
    @Override public InputStream getInputStream(){
      return null;
    }
    @Override public PrintStream getOutputStream(){
      return null;
    }
    @Override public int getPID(){
      return 0;
    }
    @Override public PrintStream getErrorStream(){
      return null;
    }
  }
,true);
  String ssh=Finder.findFileInPath(posix,"ssh",System.getenv("PATH"));
  System.out.println(ssh);
}
 

Example 39

From project aunit, under directory /junit/src/main/java/com/toolazydogs/aunit/.

Source file: Utils.java

  15 
vote

private static void doPrettyPrint(Tree tree,PrintStream out,int indent){
  for (int i=0; i < indent; i++)   out.print("  ");
  out.print("(");
  out.print(tree.toString());
  for (int i=0; i < tree.getChildCount(); i++) {
    Tree child=tree.getChild(i);
    if (child.getChildCount() > 0) {
      out.println();
      doPrettyPrint(child,out,indent + 1);
    }
 else {
      out.print(" ");
      out.print(child.toString());
    }
  }
  out.print(")");
}
 

Example 40

From project azkaban, under directory /azkaban/src/java/azkaban/jobs/.

Source file: AzkabanCommandLine.java

  15 
vote

public void printHelpAndExit(String message,PrintStream out){
  out.println(message);
  try {
    parser.printHelpOn(out);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  System.exit(1);
}
 

Example 41

From project BeeQueue, under directory /lib/src/hyperic-sigar-1.6.4/bindings/java/examples/.

Source file: Version.java

  15 
vote

private static void printNativeInfo(PrintStream os){
  String version="java=" + Sigar.VERSION_STRING + ", native="+ Sigar.NATIVE_VERSION_STRING;
  String build="java=" + Sigar.BUILD_DATE + ", native="+ Sigar.NATIVE_BUILD_DATE;
  String scm="java=" + Sigar.SCM_REVISION + ", native="+ Sigar.NATIVE_SCM_REVISION;
  String archlib=SigarLoader.getNativeLibraryName();
  os.println("Sigar version......." + version);
  os.println("Build date.........." + build);
  os.println("SCM rev............." + scm);
  String host=getHostName();
  String fqdn;
  Sigar sigar=new Sigar();
  try {
    File lib=sigar.getNativeLibrary();
    if (lib != null) {
      archlib=lib.getName();
    }
    fqdn=sigar.getFQDN();
  }
 catch (  SigarException e) {
    fqdn="unknown";
  }
 finally {
    sigar.close();
  }
  os.println("Archlib............." + archlib);
  os.println("Current fqdn........" + fqdn);
  if (!fqdn.equals(host)) {
    os.println("Hostname............" + host);
  }
  if (SigarLoader.IS_WIN32) {
    LocaleInfo info=new LocaleInfo();
    os.println("Language............" + info);
    os.println("Perflib lang id....." + info.getPerflibLangId());
  }
}
 

Example 42

From project blog_1, under directory /stat4j/src/net/sourceforge/stat4j/filter/.

Source file: MetricCollector.java

  15 
vote

public void report(PrintStream out){
  Calculator[] calcs=(Calculator[])calculators.values().toArray(new Calculator[0]);
  for (int i=0; i < calcs.length; ++i) {
    Calculator calculator=calcs[i];
    double result=calculator.getResult();
    long ts=calculator.getTimestamp();
    out.print("Statistic(" + calculator.getStatistic().getDescription() + ") value("+ result+ ") time ("+ new Date(ts)+ ")\n");
  }
}
 

Example 43

From project BMach, under directory /src/bmach/ui/gui/integration/.

Source file: FileDrop.java

  15 
vote

private static File[] createFileArray(BufferedReader bReader,PrintStream out){
  try {
    java.util.List list=new java.util.ArrayList();
    java.lang.String line=null;
    while ((line=bReader.readLine()) != null) {
      try {
        if (ZERO_CHAR_STRING.equals(line))         continue;
        java.io.File file=new java.io.File(new java.net.URI(line));
        list.add(file);
      }
 catch (      Exception ex) {
        log(out,"Error with " + line + ": "+ ex.getMessage());
      }
    }
    return (java.io.File[])list.toArray(new File[list.size()]);
  }
 catch (  IOException ex) {
    log(out,"FileDrop: IOException");
  }
  return new File[0];
}
 

Example 44

From project book, under directory /src/main/java/com/tamingtext/tagrecommender/.

Source file: TestStackOverflowTagger.java

  15 
vote

/** 
 * Dump the tag metrics 
 */
public void dumpTags(final PrintStream out,final OpenObjectIntHashMap<String> tagCounts,final OpenObjectIntHashMap<String> tagCorrect){
  out.println("-- tag\ttotal\tcorrect\tpct-correct --");
  tagCounts.forEachPair(new ObjectIntProcedure<String>(){
    @Override public boolean apply(    String tag,    int total){
      int correct=tagCorrect.get(tag);
      out.println(tag + "\t" + total+ "\t"+ correct+ "\t"+ nf.format(((correct * 100) / (float)total)));
      return true;
    }
  }
);
  out.println();
  out.flush();
}
 

Example 45

From project bpelunit, under directory /net.bpelunit.utils.testsuitestats/src/main/java/net/bpelunit/utils/testsuitestats/.

Source file: TestSuiteStats.java

  15 
vote

private static void printStats(IStatisticEntry stats,PrintStream out){
  for (  IStatisticEntry e : stats.getSubStatistics()) {
    printStats(e,out);
  }
  out.println(stats.toString());
}
 

Example 46

From project brightberry, under directory /src/me/regexp/.

Source file: REDebugCompiler.java

  15 
vote

/** 
 * Dumps the current program to a  {@link PrintStream}.
 * @param p PrintStream for program dump output
 */
public void dumpProgram(PrintStream p){
  for (int i=0; i < lenInstruction; ) {
    char opcode=instruction[i];
    char opdata=instruction[i + RE.offsetOpdata];
    int next=(short)instruction[i + RE.offsetNext];
    p.print(i + ". " + nodeToString(i)+ ", next = ");
    if (next == 0) {
      p.print("none");
    }
 else {
      p.print(i + next);
    }
    i+=RE.nodeSize;
    if (opcode == RE.OP_ANYOF) {
      p.print(", [");
      for (int r=0; r < opdata; r++) {
        char charFirst=instruction[i++];
        char charLast=instruction[i++];
        if (charFirst == charLast) {
          p.print(charToString(charFirst));
        }
 else {
          p.print(charToString(charFirst) + "-" + charToString(charLast));
        }
      }
      p.print("]");
    }
    if (opcode == RE.OP_ATOM) {
      p.print(", \"");
      for (int len=opdata; len-- != 0; ) {
        p.print(charToString(instruction[i++]));
      }
      p.print("\"");
    }
    p.println("");
  }
}
 

Example 47

From project cameraptp, under directory /src/main/java/ste/ptp/.

Source file: DeviceInfo.java

  15 
vote

private int addString(PrintStream out,int last,String s){
  last+=s.length();
  last++;
  if (last < 80) {
    out.print(s);
    out.print(" ");
  }
 else {
    out.println();
    out.print("\t");
    out.print(s);
    out.print(" ");
    last=8 + s.length() + 1;
  }
  return last;
}
 

Example 48

From project Chess_1, under directory /src/main/java/jcpi/standardio/.

Source file: AbstractStandardIoProtocol.java

  15 
vote

/** 
 * Creates a new AbstractStandardIoProtocol.
 * @param writer the standard output.
 * @param queue the engine command queue.
 */
public AbstractStandardIoProtocol(PrintStream writer,Queue<IEngineCommand> queue){
  if (writer == null)   throw new IllegalArgumentException();
  if (queue == null)   throw new IllegalArgumentException();
  this.writer=writer;
  this.queue=queue;
}
 

Example 49

From project cidb, under directory /obo2solr/src/main/java/edu/toronto/cs/cidb/obo2solr/maps/.

Source file: AbstractCollectionMap.java

  15 
vote

public void writeTo(PrintStream out){
  for (  K key : this.keySet()) {
    out.println(key + ":");
    for (    V value : this.get(key)) {
      out.println("\t" + value);
    }
  }
}
 

Example 50

From project ciel-java, under directory /examples/TeraSort/src/skywriting/examples/terasort/.

Source file: TotalOrderPartitioner.java

  15 
vote

void print(PrintStream strm) throws IOException {
  for (int ch=0; ch < 255; ++ch) {
    for (int i=0; i < 2 * getLevel(); ++i) {
      strm.print(' ');
    }
    strm.print(ch);
    strm.println(" ->");
    if (child[ch] != null) {
      child[ch].print(strm);
    }
  }
}
 

Example 51

From project CircDesigNA, under directory /src/org/apache/commons/math/.

Source file: MathException.java

  15 
vote

/** 
 * Prints the stack trace of this exception to the specified stream.
 * @param out  the <code>PrintStream</code> to use for output
 */
@Override public void printStackTrace(PrintStream out){
synchronized (out) {
    PrintWriter pw=new PrintWriter(out,false);
    printStackTrace(pw);
    pw.flush();
  }
}