JavaScript

jsp: file i/o

tomato13 2011. 6. 19. 14:24

<%@ page contentType="text/html; charset=euc-kr" pageEncoding="euc-kr"%>

<%@ page import = "java.io.*" %>

<html>

http://blog.daum.net/redcatoo/6543809


<body>

<%

FileReader fr = null;

char [] buff = new char[512];

int len = -1;

 

 try {

  fr = new FileReader(request.getRealPath("/") + "menu.txt"); //절대경로

  while((len=fr.read(buff)) != -1){

   out.print(new String(buff,0,len));

  }

 }catch(IOException ex){

  out.println("예외발생:" + ex.getMessage());

 }finally{

  if (fr != null) try { fr.close();} catch (IOException ex){}

 }

 %>


</body>

</html>



'JavaScript' 카테고리의 다른 글

use out object in a method at jsp  (0) 2011.06.19
jsp: get file list of directory  (0) 2011.06.17
jsp: get current path  (0) 2011.06.17
split  (0) 2011.06.16
j query mobile: changePage  (0) 2011.06.16