//
// Sample HelloWorld application
//
import java.lang.*;
import java.io.*;
public class Factora{ public static void main (String args[])throws IOException {
int c;
int fff;
int fac = 1;
while(true){
c = System.in.read();
System.out.println(c);
if(c == '~'){
return;
}
}
}
}//end这个结果好奇怪啊,我无论输入什么单个字符,它先输出其asccii码,接着连续输出 13 10 两个数字
如:
我输入的是a,结果:a
97
13
10是不是按回车键的关系,能不能把它解决掉,谢谢
// Sample HelloWorld application
//
import java.lang.*;
import java.io.*;
public class Factora{ public static void main (String args[])throws IOException {
int c;
int fff;
int fac = 1;
while(true){
c = System.in.read();
System.out.println(c);
if(c == '~'){
return;
}
}
}
}//end这个结果好奇怪啊,我无论输入什么单个字符,它先输出其asccii码,接着连续输出 13 10 两个数字
如:
我输入的是a,结果:a
97
13
10是不是按回车键的关系,能不能把它解决掉,谢谢
解决方案 »
- java连接access中文显示出错
- 关于java与as进行flex开发的问题
- 如何去除Applet运行时的外部边框
- 设计一程序!!
- 在jpanel上绘图 如果图比较大 显示不完 想要做下拉条 高手帮忙指点下!谢谢
- 为什么对打包的文件,在java时要用packagename.classname?
- 对象被创建时,对象的构造函数是否先于一切动作而运行呢?
- java新人求助
- 在jbuilder使用nav导航条,怎么才能当修改记录中表,自动改相连的其他表中的记录?
- 使用快速排序,在递归时,导致栈溢出的错误
- 怎样在applet里批量读取一个文件夹中的图片并在JScrollPane中显示出来?
- 如何实现 Unsigned Integer 和 byte[] 之间的互相转换
除了以下方法还有什么方法? if(c==13 || c==10)
continue;
import java.io.*;
public class Factora{ public static void main (String args[])throws IOException {
String c;
int fff;
int fac = 1;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(true){
c = in.readLine();
System.out.println(c);
if(c == "~"){
return;
}
}
}
}
import java.io.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Factora{ public static void main (String args[])throws IOException {
/*
char c='a';
int fff;
int fac = 1;
*/
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = null;
while(true){
try{str = reader.readLine();}
catch(Exception e){ }
System.out.println(str);
if(str.equals("~") ){
return;
}
}
}
}