Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

OS neutral IO code  RSS feed

 
Nimish Kanojia
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
I have an IO program which reads file from a directory(source directory) and writes files to another directory(destination directory)
I want to avoid using OS specific hardcoding in my .java files such as (/ for windows) or (\\ for unix)
I want my code to run on Solaris also.
How do i take care of this & provide .java files which dont need to recompiled when taken to a different platform.
My directory structures are deep
eg) on windows D:\testdir\test\filename.csv
How do I go about this
Kindly respond
Rgrds
Nimish
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File class has some static members available that use the system dependent path separator. You refer to them in your code, and let the File class do the rest.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!