A Funny Java Flavoured Look at the World

Wednesday, February 14, 2007

using system properties

I was doing some coding that was creating files and changing directories inside a file. I did the work initially on a windows machine, tested on a windows machine and I don't think there was any talk of a Linux machine. So of course onto the Linux machine we go, my code popped up the white flag and promptly fell flat on its backside.
I had of course heard about the nastiness of backward and forward slashes and have been drawn into the Linux world recently but thanks to the beauty of Java and it's platform independency. I recently read somewhere (and blogged about it) that Java isn't platform independent it is a platform, which I suppose is a fair point but to which doesn't really seem to be a bad thing to me (apart from a touch of bloatyness). Anyway back to the subject.

There are a number of useful values in the System object and probably the most popular is the System.out.println that a lot people use for debugging their code.

Another useful item is the


this will return the file separator used, so in my code I used this instead of using a backslash or forward slash, I used the


this will return the different file separator used for the different operating systems. I'm sure a lot of people already know about the system properties but this was just one way I found to solve problems I had when saving and reading files on different operating system.


Post a Comment

Links to this post:

Create a Link

<< Home