Created
September 26, 2021 09:59
-
-
Save vigneshrcsengg/ca6ae2681d3f5e00b1ea2aeef2a06ace to your computer and use it in GitHub Desktop.
String to Absolute File Path
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.file.FileSystems; | |
class ToAbsoluteFilePath { | |
public static void main(String args[]) { | |
System.out.println(toAbsolutePath("C:\\")); | |
} | |
public static String toAbsolutePath(String path) { | |
return FileSystems.getDefault().getPath(path).normalize().toAbsolutePath().toString(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment