菜鸟看I/O!!
来源:互联网 发布:中国电信云计算 编辑:程序博客网 时间:2024/05/17 01:41
今天看了jsp中的文件I/O技术,总体来说挺不错的.
我发现在应用该技术的时候,一定要先写上下面一段代码,
String thePath = request.getRealPath("/")+"ch11//theFile";
用来获取该文件的真实路径。
下面是一段关于文件应用的小程序。
<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'wk.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<%
String thePath=request.getRealPath("/")+"D://work//";
File myFile = new File("D://work//","work.txt");
myFile.createNewFile();
FileWriter myFileWriter = new FileWriter(myFile);
myFileWriter.write("hello,you are welcome.");
myFileWriter.flush();
myFileWriter.close();
out.println("写入成功!<br>");
char[] chrRead =new char[3600];
FileReader myFileReader = new FileReader(myFile);
myFileReader.read(chrRead);
out.println(chrRead);
myFileReader.close();
%>
</body>
</html>
- 菜鸟看I/O!!
- Python菜鸟--文件I/O
- 菜鸟浅学Java I/O总结
- Java菜鸟学习笔记--I/O篇(一):I/O Stream 简介
- java程序员从笨鸟到菜鸟之(四十)I/O流
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从Google I/O 2012看 Android 4.1的变化
- 用java的i/o读写文件,举一反三看…
- 从文件 I/O 看 Linux 的虚拟文件系统
- 从文件 I/O 看 Linux 的虚拟文件系统
- Ant 中的build.xml配置
- 十式翻译绝招
- svn 安装与配置文档(linux服务端,windows客户端)
- gridview rowcommand
- 8051内存类型
- 菜鸟看I/O!!
- 微软面试的急智题
- windows环境下emacs各种插件的安装和使用
- 给VC++贴个背景图
- 破解网页无法复制的绝招
- applet 运行时出问题了
- 如何去黑头
- ERP系统
- XPath简介