Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Files in java

410 views

Published on

introduction to files in java

  • Be the first to comment

Files in java

  1. 1. File ● A collection of data or information that has a name, called the filename. ● To access File in java, the package java.io.File must be imported. ● There are many other File based classes in the java.io package which has its own purpose
  2. 2. The Stream Classes The basic stream classes in java are ● Byte stream classes ● Character stream classes ● Standard stream classes
  3. 3. Byte Stream classes ● Java byte streams are used to perform input and output of 8-bit bytes. ● The most frequently used byte stream classes are – FileInputStream and – FileOutputStream.
  4. 4. Character stream classes ● Java Byte streams are used to perform input and output of 8-bit bytes, where as Java Character streams are used to perform input and output for 16-bit unicode. ● The most frequently used character stream classes are – FileReader and – FileWriter.
  5. 5. Standard Stream Java provides following three standard streams ● Standard Input: This is used to feed the data to user's program and usually a keyboard is used as standard input stream and represented as System.in. ● Standard Output: This is used to output the data produced by the user's program and usually a computer screen is used to standard output stream and represented as System.out. ● Standard Error: This is used to output the error data produced by the user's program and usually a computer screen is used to standard error stream and represented as System.err.
  6. 6. Sample program to write into file
  7. 7. Sample program to read from file
  8. 8. Sample output for read from file

×