It depends on your operating system. On Windows the new FileOutputStream(...)
will probably fail. On Unix-line systems you will get a new file while the old one continues to be readable.
However your copy loop is invalid. available()
is not a test for end of stream, and it’s not much use for other purposes either. You should use something like this:
byte[] buffer = new byte[8192];
int count;
while ((count = in.read(buffer)) > 0)
{
out.write(buffer, 0, count);
}
2
solved Two streams and one file