TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
<%@ page contentType="text/HTML;charset=gb2312"%>
<%@ page import="java.io.*"%>
<html>
<head>
<title>略过字节不读取</title>
</head>
<body>
<%
String path=
request.getRealPath("/article/article5a/example/filetest");
//建立FileReader对象,并实例化为fr
FileReader fr=new FileReader(new File(path, "ReadData.txt"));
out.println("当前目录:"+path+"<br>");
fr.skip(2);//跳过2个字节
out.println("读出文件的内容:"+"<br>");
int c=fr.read();//读取一个字节
while(c!=-1){
out.print((char)c);
c=fr.read();
}
fr.close();
%>
</body>
</html>
<br>附:ReadData.txt内容:<br>
ASFFFAF
3234242
源码下载:http://file.javaxxz.com/2014/10/1/015354609.zip |
|