Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- 생성자
- OGNL
- Graphic
- Android
- Menu
- layout
- 메소드
- Spring
- paint
- 메서드
- 예외처리
- JSP
- JavaScript
- AWT
- 클래스
- 이클립스
- Eclips
- Java
- HTML
- 오버로딩
- 어노테이션
- struts2
- 기본
- 배열
- 에러페이지
- 국제화
- 전화걸기
- 안드로이드
- mybatis
- oracle
Archives
- Today
- Total
note
IO Stream 키보드로 부터 한글자를 입력받아 화면에 출력 본문
package com.input;//키보드로 부터 한글자를 입력받아 화면에 출력
//ioStream
public class IOTest00 {
public static void main(String[] args) throws Exception{
int date=0;
System.out.println("문자를 입력하세요. 끝내려면 [Ctrl + Z]를 누르세요");
while((date= System.in.read()) != -1){
System.out.print((char)date);
System.out.print("\t"+date+"\n");
}//while
}//main
}
문자를 입력하세요. 끝내려면 [Ctrl + Z]를 누르세요
asdasd
a 97
s 115
d 100
a 97
s 115
d 100
13
10
package com.input; //특정 파일의 내용을 화면에 출력
import java.io.FileInputStream;
import java.io.IOException;
public class IOTest03 {
public static void main(String[] args) {
int date=0;
//c:\\filetest.txt와 동일 \특수문자 -> 경로/를 사용할 경우는 일반문자로 인식
String path ="c:/filetest.txt";
try{
FileInputStream fis = new FileInputStream(path);
while((date = fis.read())!= -1){
System.out.print((char)date);
}
}catch(IOException e){
e.printStackTrace();
}
}
}
¿?´??º Monday!!
package com.input; //특정 파일의 내용을 화면에 출력
import java.io.FileInputStream;
import java.io.IOException;
public class IOTest04 {
public static void main(String[] args) {
//c:\\filetest.txt와 동일 \특수문자 -> 경로/를 사용할 경우는 일반문자로 인식
String path ="c:/filetest.txt";
try{
FileInputStream fis = new FileInputStream(path);
byte[] date =new byte[fis.available()];
fis.read(date);
//byte[] -> String
System.out.println(new String(date));
}catch(IOException e){
e.printStackTrace();
}
}
}
오늘은 Monday!!
package com.input; //특정 파일의 내용을 화면에 출력
import java.io.FileInputStream;
import java.io.IOException;
public class IOTest05 {
public static void main(String[] args) {
int date=0;
//c:\\filetest.txt와 동일 \특수문자 -> 경로/를 사용할 경우는 일반문자로 인식
String path ="c:/filetest.txt";
try{
FileInputStream fis = new FileInputStream(path);
while((date = fis.read())!= -1){
//wirte = line by line으로 읽음 println이랑 다르게 마지막에 줄바꿈 해야됨
//줄바꿈이 되지 않았을경우 그 라인은 출력되지 않음
System.out.write(date);
}
}catch(IOException e){
e.printStackTrace();
}
}
}
오늘은 Monday!!
'자바 > 입출력' 카테고리의 다른 글
Buffer Writer (0) | 2012.01.02 |
---|---|
File Reader (0) | 2012.01.02 |
한줄 단위로 문자열 입력받아 처리하기 (0) | 2012.01.02 |
Buffer사용 (0) | 2012.01.02 |
입출력 파일 생성및 파일 읽기 (0) | 2012.01.02 |