Viv*_*ath 266
是的,您可以File
通过使用从对象获取它File.toPath()
.请记住,这仅适用于Java 7+.Java版本6及更低版本没有它.
小智 10
正如许多人所建议的,JRE v1.7及更高版本具有File.toPath();
File yourFile = ...;
Path yourPath = yourFile.toPath();
Run Code Online (Sandbox Code Playgroud)
Oracle的JDK 1.7文档这也是在上述其他职位提及,下面的等效代码是在描述用于toPath()方法,其可用于JRE V1.6工作描述;
File yourFile = ...;
Path yourPath = FileSystems.getDefault().getPath(yourFile.getPath());
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
121948 次 |
最近记录: |