我在用客户端向服务器端传输时,需要传输一个request.zip,我用流的方式进行传输,编码如下:
FileOutputStream fos = new FileOutputStream("/home/dexhia/Downloads/request.zip");
ZipOutputStream zos = new ZipOutputStream(fos, "gb2312");
zos.putNextEntry(new ZipEntry("request.xml", "gb2312"));
zos.write(xml.getBytes());
zos.closeEntry();
CipherOutputStream cos = new CipherOutputStream(zos, c);
Base64EncodingOutputStream b64os = new Base64EncodingOutputStream(cos);
BufferedOutputStream bos = new BufferedOutputStream(b64os);
String content = bos.toString();
byte[] contents;
contents = content.getBytes();
bos.close();
zos.close();OutputStream outputStream = httpurlConnection.getOutputStream();
outputStream.write(contents);
而服务器端接收解压缩的时候却发现zis.getNextEntry() 为空,恳求各位不吝赐教。
FileOutputStream fos = new FileOutputStream("/home/dexhia/Downloads/request.zip");
ZipOutputStream zos = new ZipOutputStream(fos, "gb2312");
zos.putNextEntry(new ZipEntry("request.xml", "gb2312"));
zos.write(xml.getBytes());
zos.closeEntry();
CipherOutputStream cos = new CipherOutputStream(zos, c);
Base64EncodingOutputStream b64os = new Base64EncodingOutputStream(cos);
BufferedOutputStream bos = new BufferedOutputStream(b64os);
String content = bos.toString();
byte[] contents;
contents = content.getBytes();
bos.close();
zos.close();OutputStream outputStream = httpurlConnection.getOutputStream();
outputStream.write(contents);
而服务器端接收解压缩的时候却发现zis.getNextEntry() 为空,恳求各位不吝赐教。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货