?????????java?IO??
???????????? ???????[ 2013/8/13 10:51:41 ] ????????
????IO?????????????豸???????????
?????????????????????????????????????
???????????????????????????????
???????????????????????????
?????????????????InputStream??OutputStream;
?????????????????Reader??Writer;
?????????????????????????????????????丸???????????????????
??????Writer?????????д?????????裨3?????ó?????????
????1?????????FileWriter????????????????????????????????????????????????????????????£?????????????????????????????????FileWriter fw=new FileWriter(“demo.txt”);????????????????д?????????true???????磺(“demo.txt”??true)??????????????????????????????????β????????????д??
????2??????write?????????????д?????У???fw.write(“abcda”)??
????3????????????е???????????????????????????У??磺fw.flush();??fw.close??
??????????????????????????????3?????裬??????????????FileReader)??????????????(read)??????.
??????????????????????????????
<PRE class=java name="code"><SPAN style="COLOR: #3366ff; FONT-SIZE: 18px">import java.io.*;
class FileReaderDemo
{
public static void main(String[] args)
{
FileReader fr=null;
FileWriter fw=null;
try
{
fr=new FileReader("FileWriterDemo.java");//?????????????????
fw=new FileWriter("demo.txt");//??????????д?????
char[] ch=new char[1024];//??????????飬????洢?????????
int num=0;
while((num=fr.read(ch))!=-1)
{
fw.write(ch??0??num);//??????д???????
}
}
catch (IOException e)//IO??????
{
System.out.println(e.toString());
}
finally
{
if(fr!=null)
try
{
fr.close();//??????
}
catch (IOException e)
{
System.out.println(e.toString());
}
if(fw!=null)
try
{
fw.close();
}
catch (IOException e)
{
System.out.println(e.toString());
}
}
}
}</SPAN></PRE>
<PRE></PRE>
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11