Separator Characters

A separator character is used to separate directories and files in a path. On a Windows computer, the separator character is a backslash (\). On a Linux or Mac OS X system, it’s a forward slash (/). Java processes both characters identically in a path name. For example, if we were to use the path

c:\Program Files\Java\jdk1.6.0_11\demo/jfc

which employs each separator character, Java would still process the path properly.

Image Good Programming Practice 15.1

When building Strings that represent path information, use File.separator to obtain the local computer’s proper separator character rather than ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.