我现在想把
Bufferedreader br=new Bufferedreader();
string line="";
while((line=br.readline())!=null)
{
//添加代码处
}
想把每次line的内容添加到一个文本文件里。
Bufferedreader br=new Bufferedreader();
string line="";
while((line=br.readline())!=null)
{
//添加代码处
}
想把每次line的内容添加到一个文本文件里。
解决方案 »
- java swing下线程同步的问题
- 关于jpa与jbpm整合时的事务问题
- 有才的代码
- 怎么将rar文件上传到oracle中???struts实现
- tomcat启动“死循环”
- 求一个高效的分页查询 或者 分页的存储过程
- CSDN与OSchina共建开源频道上线!
- (不设置数据源)怎么用jdbc连接后辍为.mdb的access数据库?
- 新手
- 请教在JB中建立EJB时2个问题,CMP2.0 ENTITY Bean 与BMP Entity Bean有什么区别么?有个local home interface class是什么东西??谢谢
- webservice在linux部署出错
- socket数据读写服务对外接口设计
try {
FileOutputStream out = new FileOutputStream(newFile, true);
out.write(s.toString().getBytes());
out.close();
} catch (FileNotFoundException e) {
log.error("文件找不到" + e.getMessage());
e.printStackTrace();
return false;
} catch (IOException e) {
log.error("写文件失败");
e.printStackTrace();
return false;
}s为变量既要输入的内容
public class TestData {
public static void ReadData() throws SQLException {
try {
FileReader read = new FileReader("E:/test1.txt");
BufferedReader br = new BufferedReader(read);
String row; File f = new File("E://test.txt");
if (f.exists()) {
f.delete();
}
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
PrintWriter pw = new PrintWriter(fos);
while ((row = br.readLine()) != null) {
pw.write(row);
pw.println();
pw.flush();
}
fos.close();
pw.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} public static void main(String[] args) throws Exception {
ReadData();
}
}