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.*" %>My JSP 'other.jsp' starting page <% File file=new File("C://Users//X550V//Desktop","cc.txt"); int n=-1; //定义字节数组的长度,100则表示为可以使用a[0]~a[99] byte a[]=new byte[10]; InputStream in=new FileInputStream(file); //int read() //从输出流的源中读取单个字节的数据,返回值为0~255,若为空,则返回-1 //while((n=in.read())!=-1){ //这里的n不能用in.read()代替,如果替代了,相当于第二次调用该方法,从2,4,6双字节开始读 //out.print(n+""); //} //int read(byte b[]) //从输入流的源即in中,读取长度为a.length个字节到字节数组a中,返回实际读取的字节数目,若到文件末尾,则返回-1 //in.read(a); for(int i=0;i