other.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<%@page import="java.io.*" %>
<%@page import="javax.swing.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'other.jsp' starting page</title>
</head> <body>
<%
byte b[]=new byte[2];//里面的数字决定读取的速度
try{
File file=new File("C:\\Users\\X550V\\Desktop","s.txt");
//Reader r=new FileReader(file);
//BufferedReader input=new BufferedReader(r);
FileInputStream input=new FileInputStream(file);
BufferedInputStream bufferedInput=new BufferedInputStream(input);
ProgressMonitorInputStream in=new ProgressMonitorInputStream(null,"读取文件",bufferedInput);
ProgressMonitor p=in.getProgressMonitor();
while(in.read(b)!=-1){
String str=new String(b,"gb2312");
out.print(str);
Thread.sleep(500);//文件太小,需要延缓
}
}
catch(Exception e){
out.print(e);
} %>
</body>
</html>