import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author SHASHI
*/
public class FileOutputStream1 {
public static void main(String[] args) throws IOException {
try {
FileOutputStream file = new FileOutputStream("F:\\check.txt"); // will create file with specified name and in given location
file.write(35); //be specific while writting the byte values .. it has different id for diferent symbols
file.close(); // a good practise
} catch (FileNotFoundException ex) {
Logger.getLogger(FileOutputStream1.class.getName()).log(Level.SEVERE, null, ex);
}
FileInputStream f = new FileInputStream("F:check.txt"); // will check for this file
int i =f.read(); // for reading u have to specify the content i.e, u r going to read integer content
System.out.println(" the content is " +i);
}
}
OUTPUT
the content is 17// whatever written in the file
No comments:
Post a Comment