那位高手,帮我编个JAVA程序
来源:百度知道 编辑:UC知道 时间:2024/06/27 14:26:27
我不会找,所以请把程序打出来。急急急急急。
public class TestIo1 {
public String testReader(String filePath){
String content="";
try{
Reader reader=new FileReader(filePath);
char c[]=new char[100];
int len=0;
while((len=reader.read(c, 0, 100))>0){
content+=new String(c,0,len);
}
reader.close();
}
catch (Exception e) {
e.printStackTrace();
}
return content;
}
public void testWriter(String filePath,String content){
try{
Writer writer=new FileWriter(filePath);
writer.write(content);
writer.flush();
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
TestIo1 app=new TestIo1();
String filePath="c:/data1.html";
String content=app.testReader(filePath);
System.out.println(content);
app.testWriter("c:/aaa