new PrintStream(OutputStream out) : PrintStream « java.io « Java by API






new PrintStream(OutputStream out)

 
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class MainClass {
  public static void main(String[] args) {
    try {
      File tempFile = File.createTempFile("myfile", ".tmp");
      FileOutputStream fout = new FileOutputStream(tempFile);
      PrintStream out = new PrintStream(fout);
      out.println("some text");
    } catch (IOException ex) {
      System.out.println("There was a problem creating/writing to the temp file");
      ex.printStackTrace();
    }
  }
}

           
         
  








Related examples in the same category

1.new PrintStream(File file)
2.PrintStream: print(char c)
3.PrintStream: print(int i)
4.PrintStream: print(String s)