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>