Tabnine Logo
PrintStream.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
java.io.PrintStream
constructor

Best Java code snippets using java.io.PrintStream.<init> (Showing top 20 results out of 21,690)

Refine searchRefine arrow

  • PrintStream.println
  • ByteArrayOutputStream.<init>
  • ByteArrayOutputStream.toString
  • FileOutputStream.<init>
  • PrintStream.close
  • File.<init>
  • ByteArrayOutputStream.toByteArray
origin: stackoverflow.com

 private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();

@Before
public void setUpStreams() {
  System.setOut(new PrintStream(outContent));
  System.setErr(new PrintStream(errContent));
}

@After
public void cleanUpStreams() {
  System.setOut(null);
  System.setErr(null);
}
origin: Alluxio/alluxio

 private String stacktrace(Exception e) {
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(os, true);
  e.printStackTrace(ps);
  ps.close();
  return os.toString();
 }
}
origin: netty/netty

/**
 * Gets the stack trace from a Throwable as a String.
 *
 * @param cause the {@link Throwable} to be examined
 * @return the stack trace as generated by {@link Throwable#printStackTrace(java.io.PrintWriter)} method.
 */
public static String stackTraceToString(Throwable cause) {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  PrintStream pout = new PrintStream(out);
  cause.printStackTrace(pout);
  pout.flush();
  try {
    return new String(out.toByteArray());
  } finally {
    try {
      out.close();
    } catch (IOException ignore) {
      // ignore as should never happen
    }
  }
}
origin: alibaba/jstorm

public static void redirectOutput(String file) throws Exception {
  System.out.println("Redirecting output to " + file);
  FileOutputStream workerOut = new FileOutputStream(new File(file));
  PrintStream ps = new PrintStream(new BufferedOutputStream(workerOut), true);
  System.setOut(ps);
  System.setErr(ps);
  LOG.info("Successfully redirect System.out to " + file);
}
origin: neo4j/neo4j

  void assertClosed()
  {
    if ( !c.isClosed() )
    {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      PrintStream printStream = new PrintStream( out );
      for ( StackTraceElement traceElement : stackTrace )
      {
        printStream.println( "\tat " + traceElement );
      }
      printStream.println();
      throw new IllegalStateException( format( "Closeable %s was not closed!\n%s", c, out.toString() ) );
    }
  }
}
origin: stackoverflow.com

 PrintStream fileStream = new PrintStream(new File("file.txt"));
fileStream.println("your data");
//         ^^^^^^^ will add OS line separator after data
origin: opentripplanner/OpenTripPlanner

public HTMLWriter(String filename, Multimap<String, String> curMap)
  throws FileNotFoundException {
  LOG.debug("Making file: {}", filename);
  File newFile = new File(outPath, filename +".html");
  FileOutputStream fileOutputStream = new FileOutputStream(newFile);
  this.out = new PrintStream(fileOutputStream);
  writerAnnotations = curMap;
  annotationClassName = filename;
}
origin: jenkinsci/jenkins

/**
 * Transform path for Windows.
 */
private InputStream transformForWindows(InputStream src) throws IOException {
  BufferedReader r = new BufferedReader(new InputStreamReader(src));
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  try (PrintStream p = new PrintStream(out)) {
    String line;
    while ((line = r.readLine()) != null) {
      if (!line.startsWith("#") && Functions.isWindows())
        line = line.replace("/", "\\\\");
      p.println(line);
    }
  }
  return new ByteArrayInputStream(out.toByteArray());
}
origin: redisson/redisson

public static String print2String(byte minbinMsg[]) {
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  MBPrinter.printMessage(minbinMsg, new PrintStream(os));
  try {
    return os.toString("UTF8");
  } catch (UnsupportedEncodingException e) {
    return e.getMessage();
  }
}
origin: stackoverflow.com

 import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.PrintStream;


public static void main(String [] args) {
  System.err.println("error.");
  System.out.println("out.");
  System.setOut(System.err);
  System.out.println("error?");
  System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out)));
  System.out.println("out?");
}
origin: gocd/gocd

@Test
public void shouldLoadAndBootstrapJarUsingAgentBootstrapCode_specifiedInAgentManifestFile() throws Exception {
  if (!OS_CHECKER.satisfy()) {
    PrintStream err = System.err;
    try {
      ByteArrayOutputStream os = new ByteArrayOutputStream();
      System.setErr(new PrintStream(os));
      File agentJar = new File("agent.jar");
      agentJar.delete();
      new AgentBootstrapper() {
        @Override
        void jvmExit(int returnValue) {
        }
      }.go(false, new AgentBootstrapperArgs(new URL("http://" + "localhost" + ":" + server.getPort() + "/go"), null, AgentBootstrapperArgs.SslMode.NONE));
      agentJar.delete();
      assertThat(new String(os.toByteArray()), containsString("Hello World Fellas!"));
    } finally {
      System.setErr(err);
    }
  }
}
origin: jenkinsci/jenkins

  protected Process sudoWithPass(ArgumentListBuilder args) throws IOException {
    args.prepend(sudoExe(),"-S");
    listener.getLogger().println("$ "+Util.join(args.toList()," "));
    ProcessBuilder pb = new ProcessBuilder(args.toCommandArray());
    Process p = pb.start();
    // TODO: use -p to detect prompt
    // TODO: detect if the password didn't work
    PrintStream ps = new PrintStream(p.getOutputStream());
    ps.println(rootPassword);
    ps.println(rootPassword);
    ps.println(rootPassword);
    return p;
  }
}.start(listener,rootPassword);
origin: gocd/gocd

private static void redirectStdOutAndErr() {
  try {
    PrintStream out = new PrintStream(new FileOutputStream(getOutFile(), true), true);
    System.setErr(out);
    System.setOut(out);
  } catch (FileNotFoundException ignore) {
    // cannot redirect out and err to file, so we don't
    log("Unable to redirect stdout/stderr to file " + getOutFile() + ". Will continue without redirecting stdout/stderr.");
    ignore.printStackTrace();
  }
}
origin: libgdx/libgdx

PrintStream out = new PrintStream(file, "UTF-8");
out.println("font.name=" + fontName);
out.println("font.size=" + fontSize);
out.println("font.bold=" + bold);
out.println("font.italic=" + italic);
out.println("font.gamma=" + gamma);
  out.println();
out.close();
origin: neo4j/neo4j

public static void dumpVmInfo( File directory ) throws IOException
{
  File file = new File( directory, "main-vm-dump-" + System.currentTimeMillis() );
  PrintStream out = null;
  try
  {
    out = new PrintStream( file );
    dumpVmInfo( out );
  }
  finally
  {
    if ( out != null )
    {
      out.close();
    }
  }
}
origin: stackoverflow.com

 final OutputStream os = new FileOutputStream("/tmp/out");
final PrintStream printStream = new PrintStream(os);
printStream.print("String");
printStream.close();
origin: apache/incubator-pinot

@Override
public void copyFromLocalFile(File srcFile, URI dstUri)
  throws Exception {
 OutputStream stream = _adlStoreClient.createFile(dstUri.getPath(), IfExists.OVERWRITE);
 PrintStream out = new PrintStream(stream);
 byte[] inputStream = IOUtils.toByteArray(new FileInputStream(srcFile));
 out.write(inputStream);
 out.close();
}
origin: stackoverflow.com

 public static void main(String args[]) throws IOException { 
  PrintStream ps = null;

  try {
    ps = new PrintStream(new FileOutputStream("myfile.txt"));
    ps.println("This data is written to a file:");
    System.out.println("Write successfully");
  } catch (IOException e) {
    System.err.println("Error in writing to file");
    throw e;
  } finally {
    if (ps != null) ps.close();
  }
}
origin: commons-collections/commons-collections

public void testVerbosePrintNullLabelAndMap() {
  final ByteArrayOutputStream out = new ByteArrayOutputStream();
  final PrintStream outPrint = new PrintStream(out);
  outPrint.println("null");
  final String EXPECTED_OUT = out.toString();
  out.reset();
  MapUtils.verbosePrint(outPrint, null, null);
  assertEquals(EXPECTED_OUT, out.toString());
}
origin: apache/avro

public static void writeLinesTextFile(File dir) throws IOException {
 FileUtil.fullyDelete(dir);
 File fileLines = new File(dir, "lines.avro");
 fileLines.getParentFile().mkdirs();
 try(PrintStream out = new PrintStream(fileLines)) {
  for (String line : LINES) {
   out.println(line);
  }
 }
}
java.ioPrintStream<init>

Javadoc

Constructs a new PrintStream with file as its target. The VM's default character set is used for character encoding.

Popular methods of PrintStream

  • println
    Prints an array of characters and then terminate the line. This method behaves as though it invokes
  • print
    Prints an array of characters. The characters are converted into bytes according to the platform's d
  • printf
    Prints a formatted string. The behavior of this method is the same as this stream's #format(Locale,
  • flush
    Flushes the stream. This is done by writing any buffered output bytes to the underlying output strea
  • close
    Closes the stream. This is done by flushing the stream and then closing the underlying output stream
  • format
    Writes a string formatted by an intermediate Formatter to this stream using the specified locale, fo
  • write
  • append
  • checkError
    Flushes the stream and checks its error state. The internal error state is set to true when the unde
  • setError
    Sets the error state of the stream to true. This method will cause subsequent invocations of #checkE
  • newline
    Put the line separator String onto the print stream.
  • ensureOpen
    Check to make sure that the stream has not been closed
  • newline,
  • ensureOpen,
  • newLine,
  • requireNonNull,
  • toCharset

Popular in Java

  • Creating JSON documents from java classes using gson
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now