| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 712 人关注过本帖
标题:[求助]上传文件代码????
只看楼主 加入收藏
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
 问题点数:0 回复次数:2 
[求助]上传文件代码????
急要知道JSP上传文件到文件夹的代码,不用很复杂,简单的就行
搜索更多相关主题的帖子: 文件 代码 
2005-09-10 07:14
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 
对了,我用的是TOMCAT5.0

2005-09-10 07:17
rainic
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:2367
专家分:0
注 册:2005-8-9
收藏
得分:0 

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %> <%@ page import="java.io.*"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>up</title> </head>

<body> <% try{ InputStream in=request.getInputStream(); String path=request.getRealPath("/"); File f1=new File(path+"/zht/admin","b.txt"); FileOutputStream o=new FileOutputStream(f1); byte b[]=new byte[10000]; int n; while((n=in.read(b))!=-1) { o.write(b,0,n); } o.close(); in.close();

RandomAccessFile random=new RandomAccessFile(f1,"r"); random.seek(0); long forthEndPosition=0; int forth=1; while((n=random.readByte())!=-1&&(forth<=4)) { if(n=='\n') { forthEndPosition=random.getFilePointer(); forth++; } } File f2=new File(path+"/zht/admin","c.gif"); RandomAccessFile random2=new RandomAccessFile(f2,"rw"); random.seek(random.length()); long endPosition=random.getFilePointer(); long mark=endPosition; int j=1; while((mark>=0) && (j<=6)) { mark--; random.seek(mark); n=random.readByte(); if(n=='\n') { endPosition=random.getFilePointer(); j++; } } random.seek(forthEndPosition); long startPoint=random.getFilePointer(); while(startPoint<endPosition-1); { n=random.readByte(); random2.write(n); startPoint=random.getFilePointer(); } random2.close(); random.close(); //f1.delete(); out.print("OK!"); } catch(IOException ee){out.print("fail!");} %> </body> </html> 我这样写为什么不对,我是照书写的,搞了好久都不行,请大家闺秀帮帮忙.


2005-09-10 09:11
快速回复:[求助]上传文件代码????
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024416 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved