public class test {
public static void main(String[] args) {
int ch;
try {
System.out.print("입력하고 싶은 단어 입력[Ctrl+Z:종료]");
while((ch=System.in.read())!=-1){ // 아스키코드 -1은 Ctrl+z
System.out.print(ch); //ASCII 코드
System.out.print(":"+((char)ch));
System.out.println();
}
}catch(Exception e){
}
}
}
===================================================================================
public class test {
public static void main(String[] args) {
int ch;
int n=0, s=0;
System.out.print("수?");
try{
while((ch=System.in.read())!=13){ // 아스키코드 13은 케리지리턴
n=n*10 + (ch-48);
}
for(int i=1; i<=n; i++)
s+=i;
System.out.println("1~"+n+"까지 합 : " + s);
}catch(Exception e){
}
}
}
====================================================================================
public class fffff {
public static void main(String[] args) {
int ch;
try {
System.out.print("입력하고 싶은 단어 입력[Ctrl+Z:종료]");
while((ch=System.in.read())!=-1){
char c=(char)ch;
// System.out.write(c); 한 바이트로 출력(한글안깨짐)
System.out.print(c); // 한글 깨짐
}
}catch(Exception e){
}
}
}
'자바 DB 연동 > 입출력 스트림' 카테고리의 다른 글
File 클래스 - 폴더만들기, 파일정보구하기 (0) | 2013.06.14 |
---|---|
flush 메소드 (0) | 2013.06.14 |
FileOutputStream / FileInputStream (0) | 2013.06.14 |
FileOutputStream / FileInputStream 업로드의 기초 (1) | 2013.06.14 |
InputStreamReader (1) | 2013.06.14 |