Java两行代码跨系统高效截取文件名,操作简便吗?
- 内容介绍
- 文章标签
- 相关推荐
本文共计119个文字,预计阅读时间需要1分钟。
对于以下两种路径:
- Windows系统路径:`exportPath=C:\Users\93676\Desktop\测试.docx`- Linux系统路径:`exportPath=/Users/93676/Desktop/测试1.docx`
都可以使用以下代码实现:
javaFile tempFile=new File(exportPath);
对于下边两种路径:
exportPath=“C:\Users\93676\Desktop\测试.docx” --windows系统路径
exportPath="/Users/93676/Desktop/测试1.docx" --linux系统路径
都可以使用如下两行代码解决
File tempFile = new File(exportPath.trim());
System.out.println(tempFile.getName());
本文共计119个文字,预计阅读时间需要1分钟。
对于以下两种路径:
- Windows系统路径:`exportPath=C:\Users\93676\Desktop\测试.docx`- Linux系统路径:`exportPath=/Users/93676/Desktop/测试1.docx`
都可以使用以下代码实现:
javaFile tempFile=new File(exportPath);
对于下边两种路径:
exportPath=“C:\Users\93676\Desktop\测试.docx” --windows系统路径
exportPath="/Users/93676/Desktop/测试1.docx" --linux系统路径
都可以使用如下两行代码解决
File tempFile = new File(exportPath.trim());
System.out.println(tempFile.getName());

