<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.io.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>텍스트 파일 가져와서 화면에 출력하기</title>
</head>
<body>
<%
FileReader fr = null;
char[] buf = new char[512];
int len = -1;
try{
//현재 위치 : '/' '.'
//.../AAA.jpg ./AA.jpg
String path = application.getRealPath("/");
out.print("실제 패스="+path);
fr=new FileReader(path+"/tts.txt");
while( (len = fr.read(buf)) != -1 ){
//화면에 출력하기
out.print(new String(buf,0,len));
}
}catch(Exception e){
out.print("예외발생"+e.getMessage());
}finally{
if(fr != null){
fr.close();
}
}
%>
</body>
</html>