首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Java 从源中正确读取字节

2012-08-21 
Java 从流中正确读取字节Java 从流中正确读取字节?/** * 测试用途,把响应写入文件 ** @param in */private

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);}}
?

热点排行