StreamUtil流处理
来源:互联网 发布:mac leehi 编辑:程序博客网 时间:2024/06/08 12:39
/** * 通过输入流,将其转换成字节byte数组 * * @param is * 输入的数据流 * @return byte[] 转化后的字节数组 * */ public static byte[] getByteByStream(InputStream is) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] b = new byte[1024]; int length = 0; while (length != -1) { try { length = is.read(b); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (length != -1) { baos.write(b, 0, length); } } if (is != null) { try { is.close(); is = null; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return baos.toByteArray(); } /** * 通过URL,获取输入流InputStream * * @param url * URL地址 * @return InputStream 获取输入流InputStream * */ public static InputStream getInputStreamByUrl(String url){ InputStream is = null; DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet request = new HttpGet(url);//请求方式为get try { HttpResponse response = httpClient.execute(request);//服务端响应 is = response.getEntity().getContent();//获取响应InputStream } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return is; }
- StreamUtil流处理
- StreamUtil
- 流处理
- 流处理
- 处理流
- 处理流
- 处理流
- struts图片上传,字符串处理,流处理
- 节点流 处理流
- 节点流 处理流
- delphi处理流[转]
- 字符流的处理
- 字符流的处理
- 处理声音流文件
- C++ 关于处理流
- Struts2处理流详解
- 处理流的介绍
- IO流处理
- 黑马程序员-学习日记_JAVA中异常
- 在java中调用shell
- jquery 鼠标停留显示提示框,提示框位置跟随鼠标移动
- 第03章 面向对象 34 Object类之toString方法
- word学习笔记
- StreamUtil流处理
- MediaMetadataRetriever类取得媒体文件信息
- Linux上iptables防火墙的基本应用教程
- Android 获取View在屏幕中的位置
- read函数的 用法
- Silverlight/Windows8/WPF/WP7/HTML5周学习导读(7月30日-8月5日)
- 10 款简单精美的 jQuery/CSS3 表单
- Understanding Caching
- Java数据类型