나는 내 GWT 프로젝트를 가지고 있으며 파일을 서버에 업로드하려고합니다. 나는 폴더를 압축하기 위해 다음과 같은 알고리즘)우편 번호에 폴더를 추가하는 방법
1 일
2)이 폴더
3)를 추가로 업로드 된 파일을 쓰기 "userNumber"의 이름을 가진 폴더를 만들
4) 폴더 삭제 (존재하는 경우)
나는 서버 측에 글을 쓰고 있기 때문에 나는 단지 자바 문제라고 생각한다. 여기 내 코드가있다. 첫 번째 단계와 두 번째 단계 만 수행 할 수 있습니다. 즉, 폴더를 만들고이 폴더에 파일을 쓸 수 있습니다.
@Override
public String executeAction(HttpServletRequest request,
List<FileItem> sessionFiles) throws UploadActionException {
String response = "";
userNumber = request.getParameter("userNumber");
File f = new File(ConfAppServer.getRealContextPath() + "/edoc/"
+ userNumber);
if (f.mkdir()) {
System.out.println("Directory Created");
} else {
System.out.println("Directory is not created");
}
for (FileItem item : sessionFiles) {
if (false == item.isFormField()) {
try {
String extension = item.getName().substring(
item.getName().length() - 3);
File file = null;
file = new File(ConfAppServer.getRealContextPath()
+ "/edoc/"
+ userNumber
+ System.getProperty("file.separator")
+ item.getName().substring(0,
item.getName().length() - 4) + "."
+ extension);
item.write(file);
receivedFiles.put(item.getFieldName(), file);
receivedContentTypes.put(item.getFieldName(),
item.getContentType());
response += "<file-" + cont + "-field>"
+ item.getFieldName() + "</file-" + cont
+ "-field>\n";
response += "<file-" + cont + "-name>" + item.getName()
+ "</file-" + cont + "-name>\n";
response += "<file-" + cont + "-size>" + item.getSize()
+ "</file-" + cont + "-size>\n";
response += "<file-" + cont + "-type>"
+ item.getContentType() + "</file-" + cont
+ "type>\n";
} catch (Exception e) {
throw new UploadActionException(e);
}
}
}
ZipUtils appZip = new ZipUtils(userNumber + ".zip",
ConfAppServer.getRealContextPath() + "/edoc/" + userNumber);
appZip.generateFileList(new File(ConfAppServer.getRealContextPath()
+ "/edoc/" + userNumber));
appZip.zipIt(userNumber + ".zip");
f.delete();
removeSessionFileItems(request);
return "<response>\n" + response + "</response>\n";
}
Here 내 ZipUtils
클래스를 찾을 수 있습니다.
내 폴더를 삭제하려고하면 아무 일도 발생하지 않습니다. delete() 메소드가 작동하지 않습니다. 도와주세요, 제발!! 제 질문은 zip 폴더를 추가 한 다음이 폴더를 삭제하는 방법입니다.