Topic: 为什么有时候能显示在网页上有时候是打开一个文件 |
Print this page |
1.为什么有时候能显示在网页上有时候是打开一个文件 | Copy to clipboard |
Posted by: mrs_cadbary Posted on: 2005-12-19 00:23 我用jsp写的网页,目的是在网页中打开一个文档,但为什么有时候能显示在网页上,有时候又新跳出一个文件窗口 |
2.Re:为什么有时候能显示在网页上有时候是打开一个文件 [Re: mrs_cadbary] | Copy to clipboard |
Posted by: mrs_cadbary Posted on: 2005-12-19 00:24 我的程序如下: <%@ page import="java.io.*" %> <%@ page import="java.lang.*" %> <%@ page contentType="text/html/log;charset=gb2312"%> <html> <head> <title>Lion互动网络==》JSP中读文件和写文件的例子</title> </head> <body> <% //变量声明 java.lang.String strFileName; //文件名 java.io.File objFile; //文件对象 java.io.FileReader objFileReader; //读文件对象 char[] chrBuffer = new char[10]; //缓冲 int intLength; //实际读出的字符数(一个中文为一个字符) //设置待读文件名 strFileName = "d:\\jfiles\\printname.log"; //创建文件对象 objFile = new java.io.File(strFileName); //判断文件是否存在 if(objFile.exists()){//文件存在 //创建读文件对象 objFileReader = new java.io.FileReader(objFile); BufferedReader bufferedReader = new BufferedReader(objFileReader); String currentLine; currentLine = bufferedReader.readLine(); while( (currentLine = bufferedReader.readLine()) != null ) { out.println(currentLine); } //关闭读文件对象 objFileReader.close(); } else{//文件不存在 out.println("下列文件不存在:"+strFileName); } %> </body> </html> |
3.Re:为什么有时候能显示在网页上有时候是打开一个文件 [Re: mrs_cadbary] | Copy to clipboard |
Posted by: mrs_cadbary Posted on: 2005-12-19 00:26 弹出窗口内容如下: <html> <head> <title>Lion互动网络==》JSP中读文件和写文件的例子</title> </head> <body> .. 001 (277.000.000) 11/04 20:51:44 Job executing on host: <192.168.0.121:1026> .. 005 (277.000.000) 11/04 20:51:45 Job terminated. (1) Normal termination (return value 0) Usr 0 00:00:00, Sys 0 00:00:00 - Run Remote Usage Usr 0 00:00:00, Sys 0 00:00:00 - Run Local Usage Usr 0 00:00:00, Sys 0 00:00:00 - Total Remote Usage Usr 0 00:00:00, Sys 0 00:00:00 - Total Local Usage 203 - Run Bytes Sent By Job 96 - Run Bytes Received By Job 203 - Total Bytes Sent By Job 96 - Total Bytes Received By Job .. </body> </html> *注:中间一部分是我要打开的文件中的内容 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |