Saturday, February 18, 2012

Java File Handling Program - How to Handle File in Java

It is a java example to demonstrate how to handle any File using Java programming. In this program open a file and show the complete data of file as a output.

File Name - ""
Output of this program is as same as compiled program. It's open program file and print complete program copy as a output.

Program Code
//program output is program itself which compiled
import java.util.*;
public class FILE_MAIN
 public static void main(String[] args) throws FileNotFoundException
  FileReader dataFile = new FileReader("");
  Scanner FileRead = new Scanner(dataFile);
  while (FileRead.hasNextLine())
   String Line1 = FileRead.nextLine();

Save file name as "".

It is a example of File Handling. In this program output is same copy of program itself.

Hope, it's helpful to understanding Java file handling.

No comments:

Post a Comment