📄 pipetest.java
字号:
/* * Java Network Programming, Second Edition * Merlin Hughes, Michael Shoffner, Derek Hamner * Manning Publications Company; ISBN 188477749X * * http://nitric.com/jnp/ * * Copyright (c) 1997-1999 Merlin Hughes, Michael Shoffner, Derek Hamner; * all rights reserved; see license.txt for details. */import java.io.*;
public class PipeTest extends Thread {
protected DataInputStream dataIn;
public PipeTest (InputStream in) {
dataIn = new DataInputStream (in);
}
public void run () {
try {
String line;
while ((line = dataIn.readLine ()) != null)
System.out.println (line.toUpperCase ());
dataIn.close ();
} catch (IOException ex) {
ex.printStackTrace ();
}
}
public static void main (String[] args) throws IOException, InterruptedException {
PipedOutputStream pipedOut = new PipedOutputStream ();
PipedInputStream pipedIn = new PipedInputStream (pipedOut);
PipeTest pipeTest = new PipeTest (pipedIn);
pipeTest.start ();
byte[] buffer = new byte[16];
int numberRead;
while ((numberRead = System.in.read (buffer)) > -1) {
pipedOut.write (buffer, 0, numberRead);
Thread.sleep (1000);
}
pipedOut.close ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -