Skip to content

Instantly share code, notes, and snippets.

@seyedsahil
Created January 30, 2021 05:31
Show Gist options
  • Save seyedsahil/90bcedefee2ed6c6034c161e1eebc71e to your computer and use it in GitHub Desktop.
Save seyedsahil/90bcedefee2ed6c6034c161e1eebc71e to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @author Seyed Sahil
*/
public class Main {
public static void main(String[] args) {
String fileName = "movies.txt";
Path filePath = Paths.get(fileName);
System.out.println("Path '" + filePath + "' is " + (filePath.isAbsolute() ? "absolute" : "relative"));
try {
Path realFilePath = filePath.toRealPath();
System.out.println("Path '" + realFilePath + "' is " + (realFilePath.isAbsolute() ? "absolute" :
"relative"));
} catch (IOException ex) {
ex.printStackTrace(System.err);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment