simpleio.java

来自「用java实现的Tftp(Sftp)客户端与服务器程序。在这个程序中用到了一个“」· Java 代码 · 共 21 行

JAVA
21
字号
import java.io.*;
public class SimpleIO {
	InputStream is;
	public SimpleIO(InputStream is) {
		this.is = is;
	}
	public String readString() {
		byte[] buff = new byte[128];
		int n=0;
		try {
			n = is.read(buff);
		}catch(IOException e) {
			System.out.print("不能从键盘读入");
		}
		String s = new String(buff,0,n-2);// 注意这个地方
		buff = null;
		return s;
		
	}
}

⌨️ 快捷键说明

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