티스토리 뷰

반응형

1. getResourceAsStream 이용하기
<%
 String path = "notice.txt";
 BufferedReader br = null;
 char[] buff = new char[512];
 int len = -1;
 
 try{
  br = new BufferedReader(
    new InputStreamReader(
     application.getResourceAsStream(path)
    , "UTF-8"));
  
  while((len = br.read(buff)) != -1){
   out.println(new String(buff, 0, len));
  }
 }catch(IOException ie){
  ie.getStackTrace();
 }finally{
  if(br != null){
   try{
    br.close();
   }catch(IOException ie){};
  }
 }
%>

 

2. getResource 이용하기
<%
 String path1 = "notice.txt";
 BufferedReader br1 = null;
 char[] buff1 = new char[512];
 int len1 = -1;
 
 try{
  URL url = application.getResource(path1);
  br1 = new BufferedReader(
    new InputStreamReader(
     url.openStream()
    , "UTF-8"));
  
  while((len1 = br1.read(buff1)) != -1){
   out.println(new String(buff1, 0, len1));
  }
 }catch(IOException ie){
  ie.getStackTrace();
 }finally{
  if(br != null){
   try{
    br1.close();
   }catch(IOException ie){};
  }
 }
%>

반응형

'Web Dev > JSP' 카테고리의 다른 글

[JSP] jsp:include 와 include 디렉티브의 차이  (0) 2013.06.04
[JSP] 코드 조각 자동 포함시키기  (0) 2013.06.04
[JSP] JSTL  (0) 2013.05.11
[JSP] StringTokenizer 와 String.split()  (0) 2013.04.29
[JSP] 기초  (0) 2013.04.17
댓글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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 31
글 보관함