java字节数组流模板
package IO;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class IOtest05 {
public static void main(String[] args) {
byte[] src="new byte[1024]".getBytes();
InputStream io=null;
io=new ByteArrayInputStream(src);
byte[] temp=new byte[5];
int len=-1;
try {
while((len=io.read(temp))!=-1){
String s=new String(temp,0,len);
System.out.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
byte[] dest=null;
ByteArrayOutputStream baos=new ByteArrayOutputStream();
String s="show me the code";
byte[] temp1=s.getBytes();
try {
baos.write(temp1);
dest=baos.toByteArray();
System.out.println(new String(dest));
} catch (IOException e) {
e.printStackTrace();
}
}
}