[求助]如何读取一个输出流? 大家好。我想实现一个功能就是将一段byte[] 的数据写到一个输出流中,再用一个输入流直接读取这个输出流。整体想法类似于android中的localsocket的使用,只是j2se中并没有实现这样的类。不知如何才能实现,或者有类似的好方法也可以,希望知道的朋友能指点下,谢谢先。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*; 2 3public class test { 4 public static void main(String[] args) { 5 int a=0; 6 int b=1; 7 int c=2; 8 ByteArrayOutputStream bout = new ByteArrayOutputStream(); 9 bout.write(a);10 bout.write(b);11 bout.write(c);12 byte[] buff = bout.toByteArray();13 for(int i=0; i<buff.length; i++)14 System.out.println(buff[i]);15 System.out.println("***********************");16 ByteArrayInputStream bin = new ByteArrayInputStream(buff);17 while((b=bin.read())!=-1) {18 System.out.println(b);19 }20 }21} List l=new ArrayList()和Arraylist l=new ArrayList()有什么不同啊? 请问在Eclips中有没有类似于MSDN的东西,具体怎么用啊? 难道这个问题真的没有人会吗,就这么难啊,解决不了吗? 求一份java软件开发方面的简历模板 死循环问题 求助!! 在linux下怎么设置jdk,path,classpath, 新手初写项目求助 如何用Java实现邮件的收发??? javamail中的认证机制authentication到底是干什么的? 在线等待 怎样判断一个日期是否合法? 一个小小的问题 关于JInternalFrame中插入JTable的问题
import java.io.*;
2
3public class test {
4 public static void main(String[] args) {
5 int a=0;
6 int b=1;
7 int c=2;
8 ByteArrayOutputStream bout = new ByteArrayOutputStream();
9 bout.write(a);
10 bout.write(b);
11 bout.write(c);
12 byte[] buff = bout.toByteArray();
13 for(int i=0; i<buff.length; i++)
14 System.out.println(buff[i]);
15 System.out.println("***********************");
16 ByteArrayInputStream bin = new ByteArrayInputStream(buff);
17 while((b=bin.read())!=-1) {
18 System.out.println(b);
19 }
20 }
21}