Java管道流PipedStream
来源:互联网 发布:js 24小时时间插件 编辑:程序博客网 时间:2024/05/01 05:10
package com.wj.pipedstream;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
/**
*
* @author wJing
* 管道流
*/
public class PipedStreamDemo {
public static void main(String[] args) throws Exception {
PipedInputStream in = new PipedInputStream();
PipedOutputStream out = new PipedOutputStream();
in.connect(out);
read r = new read(in);
Write w = new Write(out);
new Thread(r).start();
new Thread(w).start();
}
}
class read implements Runnable {
PipedInputStream pis = null;
public read(PipedInputStream pis) {
this.pis = pis;
}
@Override
public void run() {
try {
byte [] buf = new byte[1024];
int len = pis.read(buf);
String s = new String(buf,0,len);
System.out.println(s);
pis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
class Write implements Runnable {
PipedOutputStream pos = null;
public Write(PipedOutputStream pos) {
this.pos = pos;
}
@Override
public void run() {
try {
pos.write("abcded".getBytes());
pos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
0 0
- Java管道流PipedStream
- java管道流PipedStream
- java基础之IO流中的PipedStream管道流和RandomAcessFile
- 24-IO流-62-IO流(管道流-PipedStream)
- (92)操作对象流ObjectStream、管道流PipedStream、任意流RandomStream
- PipedStream
- java IO流 ObjectStream PipedStream 随机访问文件 字符编码--21
- Java中的管道流
- Java中的管道流
- java-管道流
- Java管道流
- java的管道流
- java 管道流
- java学习--管道流
- Java中管道流
- JAVA中的管道流
- JAVA IO-管道流
- Java管道流
- MAC中设置android 环境 cocos2d-x 开发变量
- C# 对Word文档进行处理
- Unity3d模型制作规范
- 多线程的创建
- Xcode提示“expression is not assignable”
- Java管道流PipedStream
- AsyncTask的案例 异步下载图片
- Logistic Regression--逻辑回归算法汇总**
- 联想品牌机重装系统的经验总结
- Unity3D 美术资源规范
- 【Leetcode】Word Ladder
- LingPipe使用笔记
- java对象流ObjectStream
- VS2010导入SQL数据库