Tabnine Logo
PrintStream.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
java.io.PrintStream

Best Java code snippets using java.io.PrintStream.close (Showing top 20 results out of 8,757)

Refine searchRefine arrow

  • PrintStream.<init>
  • PrintStream.println
  • FileOutputStream.<init>
  • File.<init>
  • PrintStream.print
  • ByteArrayOutputStream.<init>
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: stackoverflow.com

 File file = new File("test.log");
PrintStream ps = new PrintStream(file);
try {
  // something
} catch (Exception ex) {
  ex.printStackTrace(ps);
}
ps.close();
origin: stackoverflow.com

 final OutputStream os = new FileOutputStream("/tmp/out");
final PrintStream printStream = new PrintStream(os);
printStream.print("String");
printStream.close();
origin: java-json-tools/json-schema-validator

  optionSet = parser.parse(args);
} catch (OptionException e) {
  System.err.println("unrecognized option(s): "
    + CustomHelpFormatter.OPTIONS_JOINER.join(e.options()));
  parser.printHelpOn(System.err);
  System.err.println("cannot specify both \"--brief\" and " +
    "\"--quiet\"");
  parser.printHelpOn(System.err);
  System.err.println("missing arguments");
  parser.printHelpOn(System.err);
  System.exit(CMD_ERROR.get());
  files.add(new File(target).getCanonicalFile());
  System.out.close();
  System.err.close();
  reporter = Reporters.QUIET;
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: syncany/syncany

  private int showErrorAndExit(String errorMessage) {
    out.println("Error: " + errorMessage);
    out.println("       Refer to help page using '--help'.");
    out.println();

    out.close();

    return 1;
  }
}
origin: cmusphinx/sphinx4

/**
 * Dumps the config as a set of HTML tables
 *
 * @param ConfigurationManager the manager
 * @param path where to output the HTML
 * @throws java.io.IOException if an error occurs
 */
public static void showConfigAsHTML(ConfigurationManager ConfigurationManager, String path) throws IOException {
  PrintStream out = new PrintStream(new FileOutputStream(path));
  dumpHeader(out);
  for (String componentName : ConfigurationManager.getInstanceNames(Configurable.class)) {
    dumpComponentAsHTML(out, componentName, ConfigurationManager.getPropertySheet(componentName));
  }
  dumpFooter(out);
  out.close();
}
origin: geoserver/geoserver

  @Test
  public void testFlushOnClose() throws IOException {
    MockHttpServletResponse mockResponse = new MockHttpServletResponse();
    PartialBufferedOutputStream2 pbos = new PartialBufferedOutputStream2(mockResponse);
    PrintStream ps = new PrintStream(pbos);
    ps.print("Hello world!");
    ps.close();

    // check the in memory buffer has been flushed to the target output stream
    // close
    assertEquals("Hello world!", mockResponse.getContentAsString());
  }
}
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: cmusphinx/sphinx4

/**
 * Creates the individual batch files
 *
 * @param dir  the directory to place the input file in
 * @param name the name of the file
 * @param line the contents of the file
 */
private void createInputFile(File dir, String name, String line)
    throws IOException {
  File path = new File(dir, name);
  FileOutputStream fos = new FileOutputStream(path);
  PrintStream ps = new PrintStream(fos);
  ps.println(line);
  ps.close();
}
origin: stackoverflow.com

 public static String exceptionStacktraceToString(Exception e)
{
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(baos);
  e.printStackTrace(ps);
  ps.close();
  return baos.toString();
}
origin: sarxos/webcam-capture

private void caugh(Throwable t) {
  File f = new File(String.format("webcam-capture-hs-%s", System.currentTimeMillis()));
  PrintStream ps = null;
  try {
    t.printStackTrace(ps = new PrintStream(f));
  } catch (FileNotFoundException e) {
    e.printStackTrace();
  } finally {
    if (ps != null) {
      ps.close();
    }
  }
}
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: syncany/syncany

private int printHelpTextAndExit(String helpTextResource) throws IOException {
  String fullHelpTextResource = HELP_TEXT_RESOURCE_ROOT + helpTextResource;
  InputStream helpTextInputStream = CommandLineClient.class.getResourceAsStream(fullHelpTextResource);
  if (helpTextInputStream == null) {
    return showErrorAndExit("No detailed help text available for this command.");
  }
  for (String line : IOUtils.readLines(helpTextInputStream)) {
    line = replaceVariables(line);
    out.println(line.replaceAll("\\s$", ""));
  }
  out.close();
  return 0;
}
origin: apache/kylin

@Test
public void testGetProperty() throws IOException {
  PrintStream o = System.out;
  File f = File.createTempFile("cfg", ".tmp");
  PrintStream tmpOut = new PrintStream(new FileOutputStream(f), false, "UTF-8");
  System.setOut(tmpOut);
  KylinConfigCLI.main(new String[] { "kylin.storage.url" });
  String val = FileUtils.readFileToString(f, Charset.defaultCharset()).trim();
  assertEquals("hbase", val);
  tmpOut.close();
  FileUtils.forceDelete(f);
  System.setOut(o);
}
origin: org.apache.ant/ant

/**
 * Execute the length task.
 */
@Override
public void execute() {
  validate();
  OutputStream out =
    property == null ? new LogOutputStream(this, Project.MSG_INFO)
      : new PropertyOutputStream(getProject(), property);
  PrintStream ps = new PrintStream(out);
  switch (mode) {
  case STRING:
    ps.print(getLength(string, getTrim()));
    ps.close();
    break;
  case EACH:
    handleResources(new EachHandler(ps));
    break;
  case ALL:
    handleResources(new AllHandler(ps));
    break;
  }
}
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: jenkinsci/jenkins

/**
 * Get long description as a string.
 */
@Restricted(NoExternalUse.class)
public final String getLongDescription() {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  PrintStream ps = new PrintStream(out);
  printUsageSummary(ps);
  ps.close();
  return out.toString();
}
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: apache/flink

tempFile.setWritable(true);
PrintStream ps = new  PrintStream(tempFile);
ps.println(first);
ps.println(second);
ps.close();
System.err.println("test failed with exception: " + t.getMessage());
t.printStackTrace(System.err);
fail("Test erroneous");
java.ioPrintStreamclose

Javadoc

Closes this print stream. Flushes this stream and then closes the target stream. If an I/O error occurs, this stream's error state is set to true.

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
  • <init>
  • 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
  • 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

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Join (org.hibernate.mapping)
  • Option (scala)
  • Top Vim 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