上传大数据,采用Jszip默认压缩出的BASE64字符串,经过URL Encode处理后,提交到服务器。
private String zip = null
//Jszip
public void zipUpload(){
if (zip == null) {
System.out.println("zip is null")
return
}
try {
byte[] data = javax.xml.bind.DatatypeConverter.parseBase64Binary(zip)
InputStream is = new ZipTool().readFile(new ByteArrayInputStream(data), "data.txt")
LineReader lr = new LineReader(new InputStreamReader(is))
String line = lr.readLine()
while (line != null) {
System.out.println(line)
line = lr.readLine()
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace()
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
}
ZipTool中的readFile方法的内容:
public InputStream readFile(InputStream zipFile, String filename) throws IOException {
ZipInputStream zis = new ZipInputStream(zipFile)
ZipEntry entry = zis.getNextEntry()
while (entry != null &&(entry.isDirectory() || !entry.getName().equalsIgnoreCase(filename))) {
entry = zis.getNextEntry()
}
if (entry == null) {
return null
}
return zis
}