Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
when I try to create a new file using:
File file =new File("C:\Documents and Settings\username\My Documents\Eclipse Workspace\CH10_BasicIO\ch10\datafile1");
I get the following error:
- Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
Why isn't what I'm sending as an argument a valid pathname?
[404 byte] By [
thousea] at [2007-11-27 10:31:23]

> You need to escape the \ character in a string, and
> the escape character is the \, so to get a single \
> you need to use \\ in your string.
thanks.
> Forward slash will also work, and won't look as icky
> new File("C:/a/b/c");
Where did you pick up this icky you've been using recently?
> > Forward slash will also work, and won't look as
> icky
> > new File("C:/a/b/c");
>
> Where did you pick up this icky you've been
> using recently?
This is much better.
Forward slash is a proper file path delimiter. Backslash is for escape sequences.
jverda at 2007-7-28 18:09:16 >

> > > Forward slash will also work, and won't look as
> > icky
> > > new File("C:/a/b/c");
> >
> > Where did you pick up this icky you've been
> > using recently?
>
> This is much better.
>
> Forward slash is a proper file path delimiter.
> Backslash is for escape sequences.
heh heh no I mean the word icky!
> heh heh no I mean the word icky!
ROFL! Oohhhhh!
Um, I don't know. I've been using it for a long time. It just seems appropriate in some cases. I didn't even realize I'd used it there. Even re-reading (well, re-skimming) my post to see if that was what you were talking about. It's a bit of a fnord for me I guess.
jverda at 2007-7-28 18:09:16 >

> File file = new File("C:\\Documents and
> Settings\\username\\My Documents\\Eclipse
> Workspace\\CH10_BasicIO\\ch10\\datafile1");
See jverd's response