先上代码
public void importFile(String id, String name,int num) {
log.debug("finding importFile");
try {
id=id.trim();
//得到数据对象
byte [] content = null;
String sql = "SELECT CONTENT3 FROM MMDATA WHERE ID = '"+id+"'";
JdbcManager jdbc = new JdbcManager();
Map map = jdbc.queryElement(sql);
if(map != null)
content = (byte[]) map.get("CONTENT3");
//将data中的content值写入word文档
try {
String path = "D:\\lxf\\"+name+"_"+num+".doc"; //文件保存路径、名字
System.out.println(path);
File file = new File(path);
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
FileOutputStream out = new FileOutputStream(file);
out.write(content);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
log.debug("find importFile successful");
} catch (RuntimeException re) {
log.error("find importFile failed", re);
throw re;
}
}
如上代码,我现在能导出文件,但是它只会保存在作为服务器的那台电脑的D:\\lxf\\目录下,怎么样让文件保存在客户端的电脑上,求高手指点,感激不尽。JavaWordIO
public void importFile(String id, String name,int num) {
log.debug("finding importFile");
try {
id=id.trim();
//得到数据对象
byte [] content = null;
String sql = "SELECT CONTENT3 FROM MMDATA WHERE ID = '"+id+"'";
JdbcManager jdbc = new JdbcManager();
Map map = jdbc.queryElement(sql);
if(map != null)
content = (byte[]) map.get("CONTENT3");
//将data中的content值写入word文档
try {
String path = "D:\\lxf\\"+name+"_"+num+".doc"; //文件保存路径、名字
System.out.println(path);
File file = new File(path);
if(!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
FileOutputStream out = new FileOutputStream(file);
out.write(content);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
log.debug("find importFile successful");
} catch (RuntimeException re) {
log.error("find importFile failed", re);
throw re;
}
}
如上代码,我现在能导出文件,但是它只会保存在作为服务器的那台电脑的D:\\lxf\\目录下,怎么样让文件保存在客户端的电脑上,求高手指点,感激不尽。JavaWordIO
如果下载的话还有可能、