Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying image files

Status
Not open for further replies.

gregmosu

Programmer
Jul 8, 2002
117
US
I am trying to copy an image from one place to another and I cant figure out how to get it to work. This program copies the file(same size and all), but the image is distorted..

FileReader fr = null;
try{
fr = new FileReader("img1.jpg");
} catch(java.io.FileNotFoundException fnfe){
System.out.println(fnfe.toString());
}
try{
BufferedReader br = new BufferedReader(fr);

PrintWriter out = new PrintWriter(
new BufferedWriter(
new FileWriter(
new File("tempImg.jpg"))));


String buffer="";
while(!(null==(buffer=br.readLine()))){
out.println(buffer);
}

br.close();
out.close();
} catch(java.io.IOException ioe){
System.out.println(ioe.toString());
}
 
>> while(!(null==(buffer=br.readLine()))){

readLine is for reading "TEXT" data. Use an API that uses a byte array
Code:
byte[]

hope that helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top