This is the first code in which I am using the "int read()" based method:-
import java.io.*;
public class iokam13
{
public static void main(
String args[]) throws IOException
{
FileReader fr=new FileReader(args[0]);
BufferedReader br=new BufferedReader(fr, 1000);
FileWriter fw=new FileWriter(args[1]);
BufferedWriter bw=new BufferedWriter(fw, 1000);
int ii;
while((ii=br.read())!=-1)
{
bw.write(ii);
}
br.close();
bw.close();
System.out.println("Copy Process Complete");
}
}
**********************************************
Below is the Second code in which I am using the "String readLine()" method:-
import java.io.*;
public class iokam14
{
public static void main(String args[]) throws IOException
{
FileReader fr=new FileReader(args[0]);
FileWriter fw=new FileWriter(args[1]);
BufferedReader br=new BufferedReader(fr, 1000);
BufferedWriter bw=new BufferedWriter(fw, 1000);
String ss;
while((ss=br.readLine())!=null)
{
bw.write(ss);
}
br.close();
bw.close();
System.out.println("Copy Process Complete");
}
}
*************************************
In both the codes, I used an 11.7 MB .rtf file as an source argument. I get the file size of the destination file different for both the approaches. In case of the "int read()" method based code, I get the size as 11.7 MB, and in the code using "String readLine()" method, I get the size as 11.4 MB. Now, what happened to those 0.3 MB of data.
Thanks in advance!!
Bye,
Tualha Khan