Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File readable on windows and linux?

 
Anupam Bhatt
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic