File Copy

import java.io.*
class CopyFile
{
int ch;
//reading data from args[0]
FileInputStream fin=new FileInputStream(args[0]);
// for writing data into args[1]
FileOutputStream fout=new FileOutPutStream(args[1]);
while(ch=fin.read()!=-1){
fout.write(ch);
}
fin.close();
fout.close();
}
}

Reading a File using FileReader

import java.io.*
class ReadFile
{
public static void Main(String[] args) throws IOException{
int ch;

// check if file exist or not
FileReader fr=null;
try{
fr= new FileReader("TestFile")
}catch(Exception e){
System.out.println("File Not Found");
return;
}
// read the file till end of the file
while(ch=fr.read()!=-1){
System.out.print((char)ch);
//close the file
fr.close();
}
}

Creating a File Using File Writer

import java.io.*
class CreateFile
{
public static void Main(String[] args) throws IOException{
String text="This is The File Content on Java" + "\n i am writing This in the
File";
// Attach a file to FileWriter
FileWriter fw=new FileWriter("TestFile");
// read the character wise from string and write into file
for(int i=0;i fw.write(text.charAt(i));
//close the file
fw.close();
}
}