new File() 新建文件路径异常
在spring boot 项目中写了个压缩文件的工具类,使用的是zip4j。可是在我新建文件时路径一直不对。
然后控制台的错误信息时:
net.lingala.zip4j.exception.ZipException: net.lingala.zip4j.exception.ZipException: file does not exist: D:\WorkSpace\worldcup\C:\Users\Administrator\Desktop\world_cup.sql
Caused by: net.lingala.zip4j.exception.ZipException: file does not exist:
D:\WorkSpace\worldcup\C:\Users\Administrator\Desktop\world_cup.sql
这个路径怎么就自动改变了呢?
worldcup是我的spring boot 项目名。

File file1=new File("C:\\Users\\Administrator\\Desktop\\world_cup.sql");
File file2=new File("C:\\Users\\Administrator\\Desktop\\worldCup_ERD.xlsm");然后控制台的错误信息时:
net.lingala.zip4j.exception.ZipException: net.lingala.zip4j.exception.ZipException: file does not exist: D:\WorkSpace\worldcup\C:\Users\Administrator\Desktop\world_cup.sql
Caused by: net.lingala.zip4j.exception.ZipException: file does not exist:
D:\WorkSpace\worldcup\C:\Users\Administrator\Desktop\world_cup.sql
这个路径怎么就自动改变了呢?
worldcup是我的spring boot 项目名。

...全文
相关推荐
c++移动、复制文件,新建目录
这个函数接受两个参数,分别是源文件路径和目标文件路径。如果移动成功,源文件会被重命名为目标路径,否则会抛出一个异常。
JSP文件操作
myDelFile = new File(filePath); myDelFile.delete();%>```**解析:**- 定义文件路径为 `"c:/支出证明单.xls"`。
文件操作(Java)
以下代码展示了如何通过`java.io.File`类来删除一个文件:```java// 导入必要的包import java.io.File;// 定义文件路径File myDelFile = new File
java读取txt文件代码片段
下面是 Java 读取 TXT 文件的代码片段:```javapublic static void ReadTxt() { try { File file = new File("E:\\text.txt
java 创建txt-JAVA读取TXT文件、新建TXT文件、写入TXT文件
"; // 替换为实际文件路径 try (BufferedReader br = new BufferedReader(new FileReader(filePath))) { String line;


