Sample java FileOutputStream

import java.io.*;

class TestFilePrintWriter1 {

public static void main (String[] args) throws IOException{

File outFile = new File ("PrintDat.data");// "PrinDat.data" --> filename
FileOutputStream outStream = new FileOutputStream(outFile);
PrintWriter outWriter = new PrintWriter(outStream );
String nameis = "This is a sample String";


outWriter.println(nameis);
outWriter.println("age is 21");
outWriter.println("gender : Male");
outWriter.println('A');
outWriter.println(true);

outWriter.close();

}

}

0 comments: