ByteArrayInputStream和ByteArrayOutputStream
public class ByteArrayTest {
public static void main(String[] args) throws IOException {
read(write());
}
//read
public static void read(byte[] b) throws IOException{
InputStream is = new BufferedInputStream(new ByteArrayInputStream(b));
byte fush[] = new byte[1024];
int len = 0;
while((len=is.read(fush))!=-1){
System.out.println(new String(fush, 0,len));
}
is.close();
}
//write
public static byte[] write() throws IOException{
String s = "what the fuck write";
byte[] b = s.getBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream();
int len=b.length;
out.write(b, 0, len);
byte[] bytes = out.toByteArray();
out.close();
return bytes;
}
}
ByteArrayInputStream和ByteArrayOutputStream的更多相关文章
- [六]JavaIO之 ByteArrayInputStream与ByteArrayOutputStream
功能简介 ByteArrayInputStream 和 ByteArrayOutputStream 提供了针对于字符数组 byte [] 的标准的IO操作方式 ByteArrayInp ...
- FileInputstream,FileOutputstream 和 byteArrayInputStream,byteArrayOutputStream
你知道FileInputstream和FileOutputstream吗?FileInputstream,FileOutputstream分别是由抽象类Inputstream和Outputstream ...
- Java IO(七)ByteArrayInputStream 和 ByteArrayOutputStream
Java IO(七)ByteArrayInputStream 和 ByteArrayOutputStream 一.介绍 ByteArrayInputStream 和 ByteArrayOutputSt ...
- ByteArrayInputStream 和 ByteArrayOutputStream
package java.io; /** * A <code>ByteArrayInputStream</code> contains * an internal buffer ...
- 黑马程序猿 IO流 ByteArrayInputStream与ByteArrayOutputStream
---------------------- ASP.Net+Unity开发..Net培训.期待与您交流! ---------------------- package cn.itcast.IO; i ...
- Java IO流学习总结六:ByteArrayInputStream、ByteArrayOutputStream
类的继承关系 InputStream |__ ByteArrayInputStream OutputStream |__ ByteArrayOutputStream ByteArrayInputStr ...
- Java之IO(三)ByteArrayInputStream和ByteArrayOutputStream
转载请注明源出处:http://www.cnblogs.com/lighten/p/6972297.html 1.前言 这组输入输出流比较特殊,一般的流指定都是磁盘IO和网络IO,从文件中读取数据或者 ...
- java io流 数据流 DataInputStream、DataOutputStream、ByteArrayInputStream、ByteArrayOutputStream
例子程序: package io; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import ...
- Java I/O系列(二)ByteArrayInputStream与ByteArrayOutputStream源码分析及理解
1. ByteArrayInputStream 定义 继承了InputStream,数据源是内置的byte数组buf,那read ()方法的使命(读取一个个字节出来),在ByteArrayInputS ...
随机推荐
- Git学习:利用Git和TortoiseGit把代码传输到网络服务器
版本控制这块,一直用SVN.感觉挺好用,比VSS要好用些.不过,近期在网上,又谈到时下很流行的Git.就想看看Git到底是何方神圣.趁着五一在家无事,就静下心来,简单研究一下. 当下,网络上提供的基于 ...
- 什么是 Web API
http://www.cnblogs.com/developersupport/p/aspnet-webapi.html Web API 强势入门指南 Web API是一个比较宽泛的概念.这里我们提到 ...
- Python入门1
简介 Python的创始人为Guido van Rossum.1989年圣诞节期间,在阿姆斯特丹,Guido为了打发圣诞节的无趣,决心开发一个新的脚本解释程序,做为ABC 语言的一种继承.Python ...
- Django缓存使用方法
Django缓存分为Session和Cookie:Session为放在服务器端的缓存:Cookie为放在客户端(浏览器)的缓存. Session一般用来保存登录会话:Cookie一般用来保存一些个性化 ...
- 关于JS中的JSON
早期,一般是使用XML作为互联网上传输结构化数据的,但由于它解析麻烦,字符冗长,因此被轻量级的JSON所逐渐替代.JSON是JavaScript的一个严格子集,利用了JavaScript中一些模式来表 ...
- Windows下查看进程及结束进程命令[转]
Windows下查看进程及结束进程命令 1)查看占用8080端口的进程号 >netstat –aon | findstr “8080” 结果:TCP 0.0.0.0:8080 ...
- Bootstrap之BootstrapDialog
Make use of Bootstrap's modal more monkey-friendly. 参考地址:http://nakupanda.github.io/bootstrap3-dialo ...
- 23. Sum Root to Leaf Numbers
Sum Root to Leaf Numbers Given a binary tree containing digits from 0-9 only, each root-to-leaf path ...
- 52. Sort Colors && Combinations
Sort Colors Given an array with n objects colored red, white or blue, sort them so that objects of t ...
- 60. Insert Interval && Merge Intervals
Insert Interval Given a set of non-overlapping intervals, insert a new interval into the intervals ( ...