Re: Java under Linux differs from Java under Windows
Gordon Messmer <[email protected]> Tue, 09 Sep 2003 23:23:27 -0700
| Newsgroups | gmane.linux.redhat.release.enigma |
|---|---|
| Message-ID | <[email protected]> |
Bill Gradwohl wrote: > I've been reading Beginning Java2 SDK 1.4 Edition by Ivor Horton. ... > For Example, the renameTo method on Linux SMP deletes any target file > that may already exist, and then renames the source to that target. > Under Windows, the renameTo fails because the target file already > exists. That's normal Posix behavior. The Java documentation notes that the behavior of this function is platform dependant: http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#renameTo(java.io.File) As much as Java tries to be platform independant, not every behavior can be made consistant across platforms. The documentation notes where this will affect your code. > Another example involves random writes to an existing file. Under > Linux, all the writes get appended to the tail end of the file. Under > Windows, the writes are truly random, appearing all over the file. Which JDK are you using? I've heard reports of bugs in Java's "nio" package, which is the package that is being used for the RandomReadWrite.java example. This could be a bug in the JDK...