请问哪有有关“文件操作”的源码:急!一定给分!!

javagoo 2002-01-29 08:50:21
...全文
92 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
gzgangster 2002-01-30
String logFile ="c:/test.xls";
FileWriter fw = new FileWriter(logFile,true);
fw.write(String content);
fw.flush();
回复
gzgangster 2002-01-30
String logFile ="c:/test.xls";
FileWriter fw = new FileWriter(logFile,true);
fw.write(String content);
fw.flush();
回复
skyyoung 2002-01-30
看看java.io的库类。有很多。
回复
javagoo 2002-01-30
兄弟们的主意都不错!哎,看来还是找找!像evergreen(永远的绿)这位老兄不错噢!谢谢了! 
回复
gzgangster 2002-01-30
String logFile ="c:/test.xls";
FileWriter fw = new FileWriter(logFile,true);
fw.write(String content);
fw.flush();
回复
hexiaofeng 2002-01-30
搜索论坛
回复
pengji 2002-01-29
CSDN的翻译文档中有一片,很好的!
回复
FlyCom_NT 2002-01-29
到googl.com里搜索一下
回复
evergreen 2002-01-29
是要进行什么操作呢?读?写?
import java.io.*;

class FileReadTest {
public static void main (String[] args) {
FileReadTest t = new FileReadTest();
t.readMyFile();
}

void readMyFile() {
String record = null;
int recCount = 0;
try {
FileReader fr = new FileReader("mydata.txt");
BufferedReader br = new BufferedReader(fr);
record = new String();
while ((record = br.readLine()) != null) {
recCount++;
System.out.println(recCount + ": " + record);
}
br.close();
fr.close();
} catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}

}

---------------
import java.io.*;

class FileWriteTest {
public static void main (String[] args) {
FileWriteTest t = new FileWriteTest();
t.WriteMyFile();
}

void WriteMyFile() {
try {
FileWriter fw = new FileWriter("mydata.txt");
PrintWriter out = new PrintWriter(fw);
out.print(“hi,this will be wirte into the file!”);
out.close();
fw.close();
} catch (IOException e) {
System.out.println("Uh oh, got an IOException error!");
e.printStackTrace();
}
}

}
回复
发帖
非技术区
创建于2007-09-28

2.3w+

社区成员

Java 非技术区
申请成为版主
帖子事件
创建了帖子
2002-01-29 08:50
社区公告
暂无公告