群里发的用管道通讯的例子,用过socket,但Pipe到没用过,记下来了
来源:互联网 发布:舵机 单片机 编辑:程序博客网 时间:2024/05/01 18:16
import java.io.*;
class Piped1{
public static void main(String[] args)throws Exception{
PipedOutputStream pos=new PipedOutputStream();
PipedInputStream pis=new PipedInputStream();
try{
pos.connect(pis);
new Your(pos).start();
new MyThread(pis).start();
}catch(Exception e){
e.printStackTrace();
}
}
}
class Your extends Thread{
private PipedOutputStream pos;
Your(PipedOutputStream pos){
this.pos=pos;
}
public void run()
{
try{
pos.write("www.java.sun.com".getBytes());
pos.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
class MyThread extends Thread{
private PipedInputStream pis;
MyThread(PipedInputStream pis){
this.pis=pis;
}
public void run(){
try{
byte[] buf=new byte[1024];
int len=pis.read(buf);
// System.out.println(new String(buf,0,len));
System.out.println("HELLO");
}catch(Exception e){
e.printStackTrace();
}
}
}
- 群里发的用管道通讯的例子,用过socket,但Pipe到没用过,记下来了
- 用了一种以前没用过的方法来实现计算24点
- 一些看起来有用但没用过的函数
- 没用过的函数 GetHomePath
- Perl学了,没用过。
- 有一段时间没有来过了,大家过的好吗?
- 你可能没用过的Linux命令
- 你可能没用过的Linux命令
- 你没用过的.net4.0
- 你没用过的.net4.0
- 捡起N多年没用过的VFP6
- sql 我没用过的写法~
- sql 我没用过的写法~
- Git一些没用过的命令
- 没用过
- oracle 经常用的函数,没用过的可以学一下
- 把自己用到过的转换记下来,留待以后备用
- 找种子你还在用百度?七个你绝没用过的搜索引擎
- vdsfsdf
- C/C++面试题目汇总
- ert
- dfgfgdf
- 莫尔斯电码的趣事
- 群里发的用管道通讯的例子,用过socket,但Pipe到没用过,记下来了
- Windows Socket五种I/O模型——select模型
- Linux下安装MySQL
- asdasd
- 重装系统的纪念
- Oradim工具的用法
- Ubuntu Linux:MySQL安装指南
- 跟着我,有汤喝……
- MYSQL EMS的乱码问题解决。