memerystream1.java

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

JAVA
37
字号
import java.io.*;

class MemeryStream1
{
	public static void main(String args[])
	{
		String s="abcdefghijklmnopqrstuvwxyz";
		byte src[]=s.getBytes();//src为转换前的内存块

		ByteArrayInputStream in = new ByteArrayInputStream(src);
		ByteArrayOutputStream out = new ByteArrayOutputStream();
		transform(in,out);

		byte result[]=out.toByteArray();//result为转换后的内存块
		String t=new String(result);
		System.out.println(t);
	}
	
	public static void transform(InputStream in,OutputStream out)
	{
		int c;

		try
		{
			while((c=in.read())!=-1)
			{
				c=Character.toUpperCase((char)c);
				out.write(c);
			}
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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