Convert windows path to unix in java 2016-11-22 08:00
File separator is "/" on UNIX and "\" on Windows. Using FilenameUtils
convert path between windows and UNIX is easily. FilenameUtils.separatorsToSystem
method can help you to use correct separator.
public static void main(String[] args) {
String unixPath = "/test/linux/path";
String windowsPath = "\\test\\windows\\path";
System.out.println(FilenameUtils.separatorsToWindows(unixPath));
System.out.println(FilenameUtils.separatorsToUnix(windowsPath));
System.out.println(FilenameUtils.separatorsToSystem(windowsPath));
}
the pom file like following.
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>