Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1442252
  • 博文数量: 3500
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 43870
  • 用 户 组: 普通用户
  • 注册时间: 2008-05-03 20:31
文章分类

全部博文(3500)

文章存档

2008年(3500)

我的朋友

分类:

2008-05-04 23:44:30

一起学习
import java.io.*; public class KeyboardInput{ private final BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); public final synchronized int readInteger(){ String input=""; int value=0; try{ input=in.readLine(); } catch (IOException e){} if(input!=null){ try{ value=Integer.parseInt(input); } catch(NumberFormatException e){} } return value; } public final synchronized long readLong(){ String input=""; long value=0L; try{ input=in.readLine(); } catch (IOException e){} if(input!=null){ try{ value=Long.parseLong(input); } catch(NumberFormatException e){} } return value; } public final synchronized double readDouble(){ String input=""; double value=0.0D; try{ input=in.readLine(); } catch (IOException e){} if(input!=null){ try{ value=Double.parseDouble(input); } catch(NumberFormatException e){} } return value; } public final synchronized float readFloat(){ String input=""; float value=0.0F; try{ input=in.readLine(); } catch (IOException e){} if(input!=null){ try{ value=Float.parseFloat(input); } catch(NumberFormatException e){} } return value; } public final synchronized char readCharacter(){ char c=; try{ c=(char)in.read(); } catch (IOException e){} return c; } public final synchronized String readString(){ String s=""; try{ s=in.readLine(); } catch (IOException e){} if(s==null){ s=""; } return s; } } 下载本文示例代码


输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类输入输出类
阅读(463) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~