byte[] pFileExtend=new byte[1024];
FileOutputStream pFileOutputStream=new FileOutputStream("F:\\Site_ColligateStatistic\\UploadFile\\"+strFileName);
pFileOutputStream.write(pFileExtend);
pFileOutputStream.close();
FileOutputStream pFileOutputStream=new FileOutputStream("F:\\Site_ColligateStatistic\\UploadFile\\"+strFileName);
pFileOutputStream.write(pFileExtend);
pFileOutputStream.close();
解决方案 »
- Tomcat6发布Flex工程,使用https的问题
- 子页面如何获取父页面的bean
- 关于spring定时任务问题
- sqlserver2005到主机 的 TCP/IP 连接失败
- 请教tomcat6.0运行servlet的问题
- 把web.xml中的配置信息输出到浏览器页面,为什么中文信息为乱码?
- 一个高手都解决不了的问题 你可以吗?
- 请问如何得到调用存储过程后的记录集啊,数据库是MS-SQL2000
- 在以下数据库下要如何实现JAVABEAN功能?
- 在JSP页面循环获取Float字段的数据, 怎样去除整数末尾的.0呢?
- 在java中怎样得到文件的路径?
- 跳转页面后再回来和关闭IE,再打开原来的网页(原来的session还在);session分别是不是原来的;
<tr>
<td width="100%" valign="top">测试XMLHTTP</td>
</tr>
</table>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" valign="top">
<input type="text" value="http://10.70.38.10:9002/System/Dot/Show.jsp?Id=1" id="URLID">
<input type="text" value="C:\\DownURL.doc" id="LocalURLID">
<input type="button" value="下载" onclick="DownURL(URLID.value,LocalURLID.value);">
</td>
</tr>
</table>
<br>
<div id=App style="border:1 solid #000000;background-color:#FFFFFF;height:200px;overflow:auto;width:80%;z-index:2" contentEditable></div>
<script>
function OpenFile(strFileName)
{
try
{
var WordApp=new ActiveXObject("Word.Application");
WordApp.Application.Visible=false;
var Doc=WordApp.Documents.Open(strFileName);
Doc.Activate();
Doc.Parent.Options.InsertedTextColor=4;
Doc.Parent.Options.InsertedTextMark=2;
Doc.Parent.Options.DeletedTextColor=4;
Doc.Parent.Options.DeletedTextMark=1;
Doc.TrackRevisions=true;
Doc.PrintRevisions=true;
Doc.ShowRevisions=true;
Doc.Application.UserName="";
var Range=Doc.Range();
Range.Select();
var Selection=WordApp.Selection;
Selection.Copy();
App.focus();
document.execCommand("Paste");
App.focus();
WordApp.DisplayAlerts=false;
Doc.Close();
WordApp.DisplayAlerts=true;
WordApp.Quit();
}
catch(e)
{
window.confirm(e);
}
}
function DownURL(strRemoteURL,strLocalURL)
{
try
{
var xmlHTTP=new ActiveXObject("Microsoft.XMLHTTP");
xmlHTTP.open("Get",strRemoteURL,false);
xmlHTTP.send();
var adodbStream=new ActiveXObject("ADODB.Stream");
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(xmlHTTP.responseBody);
adodbStream.SaveToFile(strLocalURL,2);
adodbStream.Close();
adodbStream=null;
xmlHTTP=null;
OpenFile(strLocalURL);
}
catch(e)
{
window.confirm("下载URL出错!");
}
//window.confirm("下载完成.");
}
</script>
<br>
<table border="0" cellpadding="0" cellspacing="0" width="80%">
<tr>
<td width="100%" valign="top">测试XMLHTTP</td>
</tr>
</table>
现在目的就像我们常用的另存为的对话框那样指定sPathFujian+"/"+sFile开始我想我FILEDIALOG实现,但一直没有办法!你们有何高招???
SaveFileAs(sFj,sPathFujian+"/"+sFile);
public void SaveFileAs(String sFj,String filename){
try
{
// FileDialog fd =new FileDialog(this,"SaveFile",FileDialog.SAVE);
// fd.show();
// String filename = fd.getDirectory() + fd.getFile();
File file1 = new File(filename);
FileOutputStream myFileoutputstream = new FileOutputStream(file1);
byte[] buffer ;
buffer= sFj.getBytes();
int chunk = buffer.length;
myFileoutputstream.write(buffer, 0, chunk);
myFileoutputstream.close();
}
catch(Exception e){ }
}
FileDialog fileDialog=new FileDialog(m_Frame,"另存什么文件?");
fileDialog.setFile("*.doc");
fileDialog.setDirectory(".");
fileDialog.show();
String strSaveFile;
if((strSaveFile=fileDialog.getFile())!=null)
{
m_FileName.setText(strSaveFile);
m_Directory.setText(fileDialog.getDirectory());
}
else
{
m_FileName.setText("取消");
m_Directory.setText("");
}
<%
// 得到文件名字和路径
String fileName = "HousePrice.xls";
String filePath = ""; if(request.getParameter("fileName")!=null){
fileName = request.getParameter("fileName");
}
if(request.getParameter("filePath")!=null){
filePath = request.getParameter("filePath");
} String realPath = request.getRealPath("");
filePath = realPath + filePath;
System.out.println("fileName is:"+fileName);
System.out.println("filePath is:"+filePath);
// 设置响应头和下载保存的文件名
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");
// 打开指定文件的流信息
java.io.FileInputStream fileInputStream =
new java.io.FileInputStream(filePath + fileName);
// 写出流信息
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.close();
%>//这后面一定不能再有换行符,不然编译会报错
String outFileName = "filename";// 默认的文件名字和路径
response.setContentType("application/octet-stream");// 设置响应头
response.setHeader("Content-Disposition","attachment; filename=\"" + fileName + "\"");//提示IE保存文件,弹出保存文件对话框
java.io.OutputStream pw = response.getOutputStream();
pw.write(b,0,b.length); //输出字节流
pw.close();
gjd111686(数字金刚)
m_Frame??
fileDialog.setFile("*.doc");
fileDialog.setDirectory(".");
fileDialog.show();
String strSaveFile;
if((strSaveFile=fileDialog.getFile())!=null)
{
m_FileName.setText(strSaveFile);
m_Directory.setText(fileDialog.getDirectory());
}
else
{
m_FileName.setText("取消");
m_Directory.setText("");
}