Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: copying file



On Monday, April 26, 2004, at 09:51 PM, nikolaus heger wrote:
just FYI, i have some file copy code that works, but i have not tried it on windows, and it looks pretty much the same as yours... anyway, it can't hurt to try this:

in = new BufferedInputStream(new FileInputStream(source));
out = new BufferedOutputStream(new FileOutputStream(target));
byte[] buf = new byte[1000];
int n;
while ((n = in.read(buf)) != -1) {
out.write(buf, 0, n);
}
out.flush();
out.close();

Thanks, I'll check it out.

in hindsight, it's not very useful here to use buffered streams, since the stream buffer is just 512 bytes whereas i am using 1000 bytes for my buffer size... but anyway, this one worked, and if it doesnt on mac then it probably has to do with some mac-internal weirdness like file creator flags or things like that... especially Apple applications are extremely picky on what they will open... come to think of it, did you check the permissions of the newly created file? what does fc say? (fc = file compare on command line)
Yes, the permissions are identical. The byte size is tellingly different. One was about 400 bytes, and the other was about 250. Something is wrong......

Daniel
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.