如何用Java将数据库的内容保存到CSV文件 csv文件不就是逗号分隔文件吗? 你把结果集IO输出到一个文件,字段与字段间插入逗号不就好了。需要考虑的是数据记录内容中如果有逗号的话要处理一下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一個小小的example,但要你作修改, because is part of program source... :-) public void convert() throws Exception{ Iterator it_lst; PrintWriter out = null; FileOutputStream fos = null; OutputStreamWriter osw = null; StringBuffer sb = new StringBuffer(); try { fos = new FileOutputStream(path + fileName, false); osw = new OutputStreamWriter(fos ,"UTF-8"); out = new PrintWriter(osw); for(int i=0;i<3;i++){ out.println("a"+String.valueOf(i)+","+"a"+String.valueOf(i+1)); } }catch(Exception e2){ String prgPath = "convert()"; LogFile.writeLog(""); throw new Exception("Write2Xml Error: IOException"); }finally { try{ if(paraLst != null){ paraLst.clear(); paraLst = null; } if(picLst != null){ picLst.clear(); picLst = null; } if(out != null){ out.close(); out = null; } if(fos != null){ fos.close(); fos = null; } if(osw != null){ osw.close(); osw = null; } if(sb!=null){ sb = null; } }catch(IOException e){} } } 想问 还有什么框架 代替 hibernate 自己写了个类struts的框架,请大家提提意见 jsp各种错误知识? 一个简单的Java聊天室,帮我看看那里出错了. JBOSS的配置问题,谢谢 osworkflow中文文档 webwork的配置文件有一句话请大家帮忙解释一下? 晕了,HIBERNATE3出错:Could not configure datastore from input stream 这样的效果怎样实现啊? socket读取数据的问题? 在weblogic里面能不能用ACCESS数据库的? 小女子问问题,哥哥们都来帮忙啊
Iterator it_lst; PrintWriter out = null;
FileOutputStream fos = null;
OutputStreamWriter osw = null;
StringBuffer sb = new StringBuffer();
try { fos = new FileOutputStream(path + fileName, false);
osw = new OutputStreamWriter(fos ,"UTF-8");
out = new PrintWriter(osw);
for(int i=0;i<3;i++){
out.println("a"+String.valueOf(i)+","+"a"+String.valueOf(i+1));
}
}catch(Exception e2){
String prgPath = "convert()"; LogFile.writeLog("");
throw new Exception("Write2Xml Error: IOException");
}finally {
try{
if(paraLst != null){
paraLst.clear();
paraLst = null;
}
if(picLst != null){
picLst.clear();
picLst = null;
} if(out != null){
out.close();
out = null;
}
if(fos != null){
fos.close();
fos = null;
}
if(osw != null){
osw.close();
osw = null;
}
if(sb!=null){
sb = null;
}
}catch(IOException e){}
}
}