Java 从流中正确读取字节
Java 从流中正确读取字节
?
/** * 测试用途,把响应写入文件 * * @param in */private void dumpToFile(InputStream in) {FileOutputStream fos;try {String fileName = "/tmp/res-" + System.currentTimeMillis() + ".dmp";log.debug("fileName: " + fileName);fos = new FileOutputStream(fileName);byte b[] = new byte[2048];int i = -1;while ((i = in.read(b)) != -1) {fos.write(b, 0, i);}fos.close();} catch (Exception e) {log.error(e);}}?