Dear All, Thankyou for your most useful responses to date. I have another question: I would like to know how to determine whether a file EXISTS in a specified folderpath. I have attempted to do it by writing this function:- private boolean check_file(String path, String fname) { boolean status = false; File dir = new File(path); File fil = new File(dir, fname); status = fil.exists(); return status; } Trouble is, this only works if 'path' contains a string like this:- c:\\dir1\\dir2\\dir3 and not like this:- c:\dir1\dir2\dir3 Is the double slash always required ? Is there an easier way, Thanks, Steve
Steve Thanks for changing your name like Dirk asked you to. However, did you actually read the naming policy? You must not have because we ask that you use two names - a first and a last with a space in the middle. You can change you name here. Thanks [ April 30, 2002: Message edited by: Dave Vick ]
A little more on escaping: In Java string literals, the back-slash character is used to create special characters that would otherwise not be able to be embedded within the literal. Some examples are: \t for tab, \n for new-line, \r for carriage return and so on. Because the back-slash is used in this way, in order to include a 'real' back-slash in the literal you must use \\ which evaluates to a single back-slash in the literal. Thus when a Java string literal is written as "c:\\this\\that\\theother", the text that is actually stored in the resulting String object is "c:\this\that\theother". hth, bear
Well, you can certainly use System.getProperty("file.separator") - but File.separatorChar or File.separator is more efficient, as it doesn't require a Hashtable lookup using a String key for each access. Plus it's slightly less typing.
"I'm not back." - Bill Harding, Twister
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
posted
0
Yeah, what Jim said. I had misread what Monster "if-that-is-your-real-name" was saying.