Showing posts with label file to console source code in java. Show all posts
Showing posts with label file to console source code in java. Show all posts

Saturday, February 18, 2012

Java Program -File To Console

 File Handling Basic Source Code in Java
package testFileHandling;
import java.io.*;
public class File_1  {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
File infile=new File("c:\\data.txt");
//File infile_1=new File("c:\\data_1.txt");
FileReader fdr=new FileReader(infile);
//FileWriter fwr=new FileWriter(c:\\data_1.txt);
int ch ;
while((ch=fdr.read())!=-1)
{

//fwr.write((char)ch);
System.out.print((char)ch);
}

}
catch(IOException e)
{
System.out.println(e);
}
finally
{

}
}

}