Save to a text File with PrintStream in Java

Description

The following code shows how to save to a text File with PrintStream.

Example


//from www .  j  a va  2s. co  m
import java.io.FileOutputStream;
import java.io.PrintStream;

public class Main {

  public static void main(String[] a) throws Exception {
    PrintStream out = new PrintStream(new FileOutputStream("OutFile.txt"));
    out.println("demo from java2s.com");
    out.close();

  }
}




















Home »
  Java Tutorial »
    I/O »




Binary File
Byte Array
CharSet
Checksum
Console
Create Copy Move Delete
Directory
Drive
Encode Decode
File Attribute
File Lock
File System
GZIP
Jar File
NIO Buffer
Path
Scanner
StreamTokenizer
Temporary File
Text File
Zip