【发布时间】:2021-12-30 02:51:33
【问题描述】:
您好,我是 java 新手,我的英语也不好 lmao 我需要将一个文件 json (它是一个数组 json)放在一个文件 zip trought java 中,但我尝试了多种解决方案并且不起作用:(
这是我的代码:
JSONParser parser = new JSONParser();
String desktopPath =(System.getProperty("user.home")+"\\"+"Desktop");
new File(desktopPath+"\\Service Reply").mkdir();
String definitivePath = (desktopPath +"\\"+"Service Reply"+"\\");
Object obj = parser.parse(new FileReader(definitivePath+"daticliente.json"));
File f = new File(definitivePath+"//"+"test1.zip");
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f));
ZipEntry e = new ZipEntry(definitivePath+"daticliente.json");
out.putNextEntry(e);
out.closeEntry();
out.close();
有什么帮助吗? 问候
【问题讨论】:
-
“不起作用”是什么意思?请添加错误消息和预期与实际结果等。
-
欢迎回复我,代码创建了文件 zip,但没有将我之前创建的文件 json 放入文件 zip 中。