bufferstream1.java

来自「这是清华大学编写的JAVA教材中所有题目的源代码!」· Java 代码 · 共 39 行

JAVA
39
字号
import java.io.*;

class BufferStream1
{
	public static void main(String args[])
	{
		try
		{
	    	BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream("hello.txt"));
			out.write("hello world中国".getBytes());
			String a="ab中国";
			byte b[]=a.getBytes();
		
		
			System.out.print(b.length);
			out.close();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}

		try
		{
			BufferedInputStream in = new BufferedInputStream(new FileInputStream("hello.txt"));
			int c;
		
			while((c=in.read())!=-1)
				System.out.print((char)c);
			
			System.out.println();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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