1
3 개의 csv 파일이 포함 된 폴더의 압축을 풀고 각 csv 파일의 데이터를 인쇄 할 수있는 서블릿을 만들려고합니다.Google App Engine (Java)에서 각 파일을 압축 해제하고 읽어들이십시오.
저는 ZipInputStream을 사용하려고했지만 각 CSV의 내용을 읽고 인쇄 할 수있는 기능을 제공하지 않습니다.
GAE에서이 웹 응용 프로그램을 제작할 때 FileOutputStream을 사용할 수 없습니다.
GAE에서 csv를 만들 필요없이 ZipInputStream을 사용하여 개별 csv의 압축을 풀고 읽는 방법이 있습니까? 당신이 정상으로 그것에서 읽을 수 있도록
공용 클래스 AdminBootStrap가 확장 HttpServlet을가 {
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
PrintWriter out = resp.getWriter();
try {
ServletFileUpload upload = new ServletFileUpload();
resp.setContentType("text/plain");
FileItemIterator iterator = upload.getItemIterator(req);
while (iterator.hasNext()) {
FileItemStream item = iterator.next();
InputStream in = item.openStream();
if (item.isFormField()) {
out.println("Got a form field: " + item.getFieldName());
} else {
out.println("Got an uploaded file: " + item.getFieldName() +
", name = " + item.getName());
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(in));
ZipEntry entry;
// Read each entry from the ZipInputStream until no
// more entry found indicated by a null return value
// of the getNextEntry() method.
//
while ((entry = zis.getNextEntry()) != null) {
out.println("Unzipping: " + entry.getName());
//until this point, i'm only available to print each csv name.
//What I want to do is to print out the data inside each csv file.
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
// throw new ServletException(ex);
}
}
}
이해 내가 그 다음을 사용하여 데이터를 인쇄 할 수 있습니다. System.out.write (buf, 0 , len); 그러나이 데이터를 String 변수에 곧바로 저장할 수 있습니까? – chuntato