달력

4

« 2024/4 »

  • 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

2015.07 http://suite.tistory.com/


package 화된 jar 파일내 파일 읽기 함수 샘플


1. 파일 존재 확인 


if( this.getClass().getResource( "/file name") == null ) 이면 없는 거임

  * 절대 경로로 / 부터 찾기   , jar fxv pack.jar 풀어서 경로를 미리 보고 입력해도 됨 


2. stream -> BufferedReader -> readLine 


BufferedReader in=new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream( "/file name"), "UTF-8"));

String strLine = "";

while ((strLine = in.readLine()) != null) {

System.out.println("readLine"  + strLine);

}


:
Posted by mastar