Alessandro Lacava

on Designing and Developing Software. In love with Functional Programming.

The Name-separator Character In Java

Java was born as a platform-independent programming language. Some features that grant the platform independence are achieved using the APIs of the language itself. For example, to construct a filename path, you can use the public static field separator of the java.io.File class.

Example:

1
String path = java.io.File.separator + "foldername" + java.io.File.separator + "filename";

This produces the string /foldername/filename under Unix-like systems and \foldername\filename under Windows systems.

Comments