- 浏览: 177394 次
- 性别:
- 来自: 武汉
文章分类
- 全部博客 (150)
- mysql (8)
- ssh (2)
- 总结 (14)
- 个人心扉 (5)
- 网摘 (14)
- 其它 (2)
- javascript (0)
- ajax (3)
- jquery (0)
- 正则表达式 (2)
- 我们的项目 (1)
- Java代理(静态和动态) (2)
- java (19)
- jsp (5)
- servlet (1)
- uml (0)
- java 细节常识 (1)
- 学习网址哈哈 (2)
- python (5)
- Wearing other`s shoes (6)
- jdbc (1)
- JMeter (18)
- 测试 (9)
- linux操作 (2)
- couchdb (0)
- ruby (20)
- QTP资源地址 (1)
- rspec 范例 (1)
- LR (3)
- spring (1)
- 自动化 (2)
- 无线测试相关 (1)
最新评论
-
1336224635:
...
EJB -
guanzhongdaoke54007:
很好很强大~[color=blue][/color][size ...
ResultSet -
enum:
thank's so mauch.
font color to ...
java生成登录验证码的方法 -
harbey:
文章很好,很受用!
转帖Jmeter中的几个重要测试指标释义 -
xiangguanglei:
非常感谢!这个问题苦恼了我很久。
关于ruby + watir
[size=small]
<%@ page contentType="text/html;charset=gb2312"%>
<%
String filePath="c:/aaa/";
filePath=filePath.toString();//中文转换
java.io.File myFilePath=new java.io.File(filePath);
if(!myFilePath.exists())
myFilePath.mkdir();
%>
2。新建文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<%
String filePath="c:/哈哈.txt";
filePath=filePath.toString();
File myFilePath=new File(filePath);
if(!myFilePath.exists())
myFilePath.createNewFile();
FileWriter resultFile=new FileWriter(myFilePath);
PrintWriter myFile=new PrintWriter(resultFile);
String strContent = "中文测试".toString();
myFile.println(strContent);
resultFile.close();
%>
3。删除文件
<%@ page contentType="text/html;charset=gb2312"%>
<%
String filePath="c:/支出证明单.xls";
filePath=filePath.toString();
java.io.File myDelFile=new java.io.File(filePath);
myDelFile.delete();
%>
4。文件拷贝
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
int bytesum=0;
int byteread=0;
file://读到流中
InputStream inStream=new FileInputStream("c:/aaa.doc");
FileOutputStream fs=new FileOutputStream( "d:/aaa.doc");byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
inStream.close();
%>
5。整个文件夹拷贝
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<%String url1="C:/aaa";
String url2="d:/java/";
(new File(url2)).mkdirs();
File[] file=(new File(url1)).listFiles();
for(int i=0;i<file.length;i++){
if(file.isFile()){
file.toString();
FileInputStream input=new FileInputStream(file);
FileOutputStream output=new FileOutputStream(url2+"/"+(file.getName()).toString());
byte[] b=new byte[1024*5];
int len;
while((len=input.read(b))!=-1){
output.write(b,0,len);
}
output.flush();
output.close();
input.close();
}
}
%>
6。文件下载
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
String fileName = "zsc104.swf".toString();
//读到流中
InputStream inStream=new FileInputStream("c:/zsc104.swf");
//设置输出的格式
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition","attachment; filename="" + fileName + """);
//循环取出流中的数据
byte[] b = new byte[100];
int len;
while((len=inStream.read(b)) >0)
response.getOutputStream().write(b,0,len);
inStream.close();
%>
7。数据库字段中的文件下载
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.jspsmart.upload.*" %>
<%@ page import="DBstep.iDBManager2000.*"%>
<%
int bytesum=0;
int byteread=0;
//打开数据库
ResultSet result=null;
String Sql=null;
PreparedStatement prestmt=null;
DBstep.iDBManager2000 DbaObj=new DBstep.iDBManager2000();
DbaObj.OpenConnection();
//取得数据库中的数据
Sql="select * from t_local_zhongzhuan ";
result=DbaObj.ExecuteQuery(Sql);
result.next();
file://将数据库中的数据读到流中
InputStream inStream=result.getBinaryStream("content");
FileOutputStream fs=new FileOutputStream( "c:/dffdsafd.doc");
byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
%>
8。把网页保存成文件
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.net.*"%>
<%
URL stdURL = null;
BufferedReader stdIn = null;
PrintWriter stdOut = null;
try {
stdURL = new URL("http://www.163.com");
}
catch (MalformedURLException e) {
throw e;
}
try {
stdIn = new BufferedReader(new InputStreamReader(stdURL.openStream()));
stdOut = new PrintWriter(new BufferedWriter(new FileWriter("c:/163.html")));
}
catch (IOException e) {
}
/***把URL指定的页面以流的形式读出,写成指定的文件***/
try {
String strHtml = "";
while((strHtml = stdIn.readLine())!=null) {
stdOut.println(strHtml);
}
}
catch (IOException e) {
throw e;
}
finally {
try {
if(stdIn != null)
stdIn.close();
if(stdOut != null)
stdOut.close();
}
catch (Exception e) {
System.out.println(e);
}
}
%>
9。直接下载网上的文件
<%@ page import="java.io.*"%>
<%@ page import="java.net.*"%>
<%
int bytesum=0;
int byteread=0;
URL url = new URL("http://pimg.163.com/sms/micheal/logo.gif");
URLConnection conn = url.openConnection();
InputStream inStream = conn.getInputStream();
FileOutputStream fs=new FileOutputStream( "c:/abc.gif");
byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
%> [/size]
<%@ page contentType="text/html;charset=gb2312"%>
<%
String filePath="c:/aaa/";
filePath=filePath.toString();//中文转换
java.io.File myFilePath=new java.io.File(filePath);
if(!myFilePath.exists())
myFilePath.mkdir();
%>
2。新建文件
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<%
String filePath="c:/哈哈.txt";
filePath=filePath.toString();
File myFilePath=new File(filePath);
if(!myFilePath.exists())
myFilePath.createNewFile();
FileWriter resultFile=new FileWriter(myFilePath);
PrintWriter myFile=new PrintWriter(resultFile);
String strContent = "中文测试".toString();
myFile.println(strContent);
resultFile.close();
%>
3。删除文件
<%@ page contentType="text/html;charset=gb2312"%>
<%
String filePath="c:/支出证明单.xls";
filePath=filePath.toString();
java.io.File myDelFile=new java.io.File(filePath);
myDelFile.delete();
%>
4。文件拷贝
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
int bytesum=0;
int byteread=0;
file://读到流中
InputStream inStream=new FileInputStream("c:/aaa.doc");
FileOutputStream fs=new FileOutputStream( "d:/aaa.doc");byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
inStream.close();
%>
5。整个文件夹拷贝
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.io.*" %>
<%String url1="C:/aaa";
String url2="d:/java/";
(new File(url2)).mkdirs();
File[] file=(new File(url1)).listFiles();
for(int i=0;i<file.length;i++){
if(file.isFile()){
file.toString();
FileInputStream input=new FileInputStream(file);
FileOutputStream output=new FileOutputStream(url2+"/"+(file.getName()).toString());
byte[] b=new byte[1024*5];
int len;
while((len=input.read(b))!=-1){
output.write(b,0,len);
}
output.flush();
output.close();
input.close();
}
}
%>
6。文件下载
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.io.*" %>
<%
String fileName = "zsc104.swf".toString();
//读到流中
InputStream inStream=new FileInputStream("c:/zsc104.swf");
//设置输出的格式
response.reset();
response.setContentType("bin");
response.addHeader("Content-Disposition","attachment; filename="" + fileName + """);
//循环取出流中的数据
byte[] b = new byte[100];
int len;
while((len=inStream.read(b)) >0)
response.getOutputStream().write(b,0,len);
inStream.close();
%>
7。数据库字段中的文件下载
<%@ page contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.jspsmart.upload.*" %>
<%@ page import="DBstep.iDBManager2000.*"%>
<%
int bytesum=0;
int byteread=0;
//打开数据库
ResultSet result=null;
String Sql=null;
PreparedStatement prestmt=null;
DBstep.iDBManager2000 DbaObj=new DBstep.iDBManager2000();
DbaObj.OpenConnection();
//取得数据库中的数据
Sql="select * from t_local_zhongzhuan ";
result=DbaObj.ExecuteQuery(Sql);
result.next();
file://将数据库中的数据读到流中
InputStream inStream=result.getBinaryStream("content");
FileOutputStream fs=new FileOutputStream( "c:/dffdsafd.doc");
byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
%>
8。把网页保存成文件
<%@ page import="java.text.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.net.*"%>
<%
URL stdURL = null;
BufferedReader stdIn = null;
PrintWriter stdOut = null;
try {
stdURL = new URL("http://www.163.com");
}
catch (MalformedURLException e) {
throw e;
}
try {
stdIn = new BufferedReader(new InputStreamReader(stdURL.openStream()));
stdOut = new PrintWriter(new BufferedWriter(new FileWriter("c:/163.html")));
}
catch (IOException e) {
}
/***把URL指定的页面以流的形式读出,写成指定的文件***/
try {
String strHtml = "";
while((strHtml = stdIn.readLine())!=null) {
stdOut.println(strHtml);
}
}
catch (IOException e) {
throw e;
}
finally {
try {
if(stdIn != null)
stdIn.close();
if(stdOut != null)
stdOut.close();
}
catch (Exception e) {
System.out.println(e);
}
}
%>
9。直接下载网上的文件
<%@ page import="java.io.*"%>
<%@ page import="java.net.*"%>
<%
int bytesum=0;
int byteread=0;
URL url = new URL("http://pimg.163.com/sms/micheal/logo.gif");
URLConnection conn = url.openConnection();
InputStream inStream = conn.getInputStream();
FileOutputStream fs=new FileOutputStream( "c:/abc.gif");
byte[] buffer =new byte[1444];
int length;
while ((byteread=inStream.read(buffer))!=-1)
{
out.println("<DT><B>"+byteread+"</B></DT>");
bytesum+=byteread;
System.out.println(bytesum);
fs.write(buffer,0,byteread);
}
%> [/size]
发表评论
-
File源码理解
2015-01-07 15:30 01.构造函数 最基本的构造方法。 Java代码 ... -
java 定时器
2014-07-30 17:41 0java的Timer以及TimerTask类可以帮助我们实现 ... -
折半查找
2009-03-15 20:57 1028http://www.hiahia.org/datastruc ... -
Tomcat服务器
2009-03-15 10:04 753一、Tomcat背景 自从JSP发布之后,推出了各式各样 ... -
冒泡排序
2009-03-15 09:31 824目的:按要求从大到小或从小到大排序。 基本思路:对尚未排 ... -
字符串反转
2009-03-05 21:03 1341public class Fanzhuan { publ ... -
DOM模型概述
2009-02-27 22:02 1016自从W3C建立了DOM标准 (W3 ... -
常用集合类的区别
2009-02-22 23:49 863线性表,链表,哈希表 ... -
什么是数据库死锁
2009-02-22 20:12 2319什么是数据库死锁 每个使用关系型数据库的程序都可能 ... -
详细分析不同类型数据库的死锁问题
2009-02-22 19:52 957关键字: 详细 类型 数据 ... -
java生成登录验证码的方法
2009-02-22 10:28 2778引用 验证码的作用 ... -
Object.toString()方法
2009-02-22 01:33 1751[size=medium]在java项目的 ... -
Java 中Iterator 、Vector、Array
2009-02-22 01:27 1425线性表,链表,哈希表 ... -
java.io包中的流文件、文件类
2009-02-22 01:25 998[color=white] 视频认证 ... -
如何从文件中读取数据
2009-02-22 01:21 998public void readDate(String fi ... -
java.io包
2009-02-22 01:18 811java.io包难吗?2008-04-03 16:58j ... -
彻底明白Java的IO系统
2009-02-22 01:16 675一. Input和Output 1. strea ... -
ResultSet
2009-02-22 01:06 1410结果集(ResultSet)是数据中查询结果返回的一种对象,可 ... -
过滤器
2009-02-22 00:58 848其实很多的JavaWEB开发 ... -
EJB
2009-02-22 00:48 1245EJB是sun的服务器端 ...
相关推荐
本文实例讲述了Android编程获取图片数据的方法。分享给大家供大家参考,具体如下: 网络的访问在我们日常生活中太重要了,如果没有网络我们的生活将会是什么样子呢?Android手机和浏览器也是一样的,也可以通过网络...
1.2.2 ........................................................................................................5 使用场景 2 ................................................................................
java8 看不到源码库尔贝尔特 Kotlin 的一堆有用的扩展。 文档 那是什么...? 不,但说真的,弄清楚这里有什么的最好方法可能是阅读单元测试。 我尽量保持这个模块经过充分测试。 core工件中的大多数方法都有一个测试...
8.3 java.io.Writer这个类从JDK 1.4到JDK 5的演进 131 8.4 合理分解API 143 第9章 牢记可测试性 147 9.1 API设计和测试 148 9.2 规范的光环正在褪去 151 9.3 好工具让API设计更简单 153 9.4 兼容...
2、负责信息系统的安装及日常运维,包括接听客户咨询电话,向用户提供咨询、指导、 解释相关业务或技术问题,收集并及时反馈用户信息; 3、负责用户培训,编写培训文档、使用手册、测试文档,解答用户系统使用过程...
2、负责信息系统的安装及日常运维,包括接听客户咨询电话,向用户提供咨询、指导、解释相关业务或技术问题,收集并及时反馈用户信息; 3、负责用户培训,编写培训文档、使用手册、测试文档,解答用户系统使用过程中...
2、负责信息系统的安装及日常运维,包括接听客户咨询电话,向用户提供咨询、指导、 解释相关业务或技术问题,收集并及时反馈用户信息; 3、负责用户培训,编写培训文档、使用手册、测试文档,解答用户系统使用过程...
2、负责信息系统的安装及日常运维,包括接听客户咨询电话,向用户提供咨询、指导、 解释相关业务或技术问题,收集并及时反馈用户信息; 3、负责用户培训,编写培训文档、使用手册、测试文档,解答用户系统使用过程...
Toad 使用快速入门 目录 一.Toad功能综述 二.系统需求 三.安装指南 四.快速入门 1. Schema browser的用法简介 2. SQL Editor的使用介绍 3. Procedure Editor的用法介绍 4. 如何进行PLSQL的debug 5. 如何...
只有在使用故障恢复控制台时,才能使用 fixboot 命令。 fixboot [drive] 参数 驱动器 将要写入引导扇区的驱动器。它将替代默认的驱动器(即用户登录的系统分区)。例如,驱动器:D: 范例 下列命令...
基本使用方法 假设有一个类叫PlainObject,它有一个方法叫functionA(String str) 如果你想给PlainObject#functionA(String)加一个约束,让functionA的参数不能为空,你可以这样声明functionA public class ...