This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes File readable on windows and linux? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Reply Bookmark "File readable on windows and linux?" Watch "File readable on windows and linux?" New topic
Author

File readable on windows and linux?

Anupam Bhatt
Ranch Hand

Joined: Mar 12, 2004
Posts: 81
Hi,
i dont know if its the right forum but asking :

I am facing a issue, so need some clue. one of my tests[coded in java] reads a text file [which is in dos format]. Since the text file is in dos format the test fails on linux when it compares some content with the content of the file [it should pass actually as its the same content].

When i change the file format to unix mode, everything is fine.
However then the test wont pass on Windows [this is my guess and i think i am correct]

How can i make the test pass with both windows and linux ?

Thanks,
Anupam
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8263

Unix and Windows use different line separators. If you are using a method that utilizes the os-dependent line separator, like BufferedReader.readLine(), you will have problems trying to use the same file on different OS's.
Some solutions would be to parse the file for the line separator yourself or use something other than a plain text file (binary, XML, serialized collection, etc.).


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: File readable on windows and linux?
 
Similar Threads
FTP Put a zip file that contains text files in Linux
ASCII encoding in WordPad
dos output
passing an object to a method
difference between Java, VisualBasic & C