Hi guys,
Have a little problem copying files using
Java...
I can copy the file OK, and all appears well, until you try to open the file. Then no matter what the file type (although mine are primarily images) you get the following error:-
XXX can not read this file
This is not a valid XXX file or it's format is not curremtly supported
Here is my code (Note the DestinationFolder, DestinationFile, SourceFile etc are all valid, i just haven't showed how they are parsed as it is too long):-
DestinationFolder.mkdir();
Destination.createNewFile();
InputStream input = new FileInputStream(SourceFile);
OutputStream output = new FileOutputStream(DestinationFile);
byte[] buffer = new byte[1024];
int length = input.read();
while ((length = input.read(buffer)) > 0) {
output.write(buffer, 0, length);
}
input.close();
output.close();