java 字节流和字符流转换类InputStreamReader,OutPutStreamReader


java 字节流和字符流转换类InputStreamReader,OutPutStreamReader_第1张图片

import java.io.*;

public class BufferDemo
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader buf=null;
		
		buf=new BufferedReader(new InputStreamReader(System.in));
		System.out.print("Please enter a number:");
		String str=buf.readLine();
		//将字符串解析为整数
		int i=Integer.parseInt(str);
		i=i+10;
		System.out.println("The modified number is "+i+".");
	}
}


你可能感兴趣的:(Java)