⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zh.txt

📁 将一组英文单词或者句子中的小写装换成大写
💻 TXT
字号:
import java.io.*;
public class PipedStreamEaxm {
	public static void main (String[]args)throws IOException{
		try{
			Sender t1 = new Sender();
			Receiver t2 = new Receiver();
			PipedOutputStream pout =t1.getOutputStream();
			PipedInputStream pin = t2.getInputStream();
			pout.connect(pin);
			t1.start();
			t2.start();
		}
		catch (IOException e){
			System.out.println(e.getMessage());
		}
		}
	}
class Sender extends Thread{
	private PipedOutputStream pout = new PipedOutputStream();
	public PipedOutputStream getOutputStream() {
		return pout;
	}
	public void run(){
	String s = new String("Hello,receiver,how are you?");
	try{
		for(int i=0;i<5;i++){
			pout.write(i);
		}
		pout.write(s.getBytes());
		pout.close();
	}
	catch (IOException e){
		System.out.println(e.getMessage());
	}
	}
}
class Receiver extends Thread{
	private PipedInputStream pin = new PipedInputStream();
	public PipedInputStream getInputStream(){
		return pin;
	}
	public void run(){
		String s = null;
		byte[] buf = new byte[1024];
		try{
			int c,i=0;
			System.out.println("Receiver 5 numbers: ");
			while(i++<5&&(c=pin.read())!=-1)
				System.out.println(c);
			int len=pin.read(buf);
			s = new String(buf,0,len);
			System.out.println("\nThe following string comes from sender:"+s);
			pin.close();
		}
		catch (IOException e){
			System.out.println(e.getMessage());
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -