file,path,uri互相转换

uri 转 file :File file = new File(new URI(uri.toString()));

uri 转 path: Path path = Files.get(uri);

file 转 uri: URI uri = file.toURI();

file 转 path: Path path = Paths.get(file.getPath());

path 转 uri: URI uri = path.toUri()

path 转 file: File file = new File(path.toUri());

原文地址:https://www.cnblogs.com/rayallenbj/p/9340394.html