已经能够从数据库中把一张表的列名及其数据读出,然后写入到TXT文档中,
发现个问题 为什么总是只有最后一行数据!急~~~在线等 最好给点代码!
try{ 对数据库的查询
}catch(Exception e){
e.printStackTrace();
}
把查到的数据存到名为abc1的TXT中
String s =result;
fw.write(s,0,s.length());
fw.flush();
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("e:\\abc1.txt"));
osw.write(s,0,s.length());
osw.flush();
PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream("e:\\abc1.txt")),true);
pw.println(s);
fw.close();
osw.close();
pw.close();
}
最后在TXT中就只有最后一行的数据 为什么呢?