android 手记之 IO流

来源:互联网 发布:南京秦淮网络问政 编辑:程序博客网 时间:2024/04/29 10:56
学习了几天android 刚开始学习androi的组件的时候 比如 Button,TextView ,ProgressBar……等等 到是不难 但是学到后面 ,要想真正开发android的程序 线程和IO一定要学好
所以……
import java.io.*;/*public class FileWriterDemo{public static void main(String args[]) throws IOException{         FileWriter fw=new FileWriter("tex.txt"); //writer() 方法只是写入字符到一个缓冲区,并没有真正的写入tex.txt中 fw.write("helloWorld"); //此时需要刷新缓冲区,把字符读入文件中。 fw.flush(); fw.close();}}*/public class FileWriterDemo{public static void main(String args[]){FileWriter fw = null;try{fw=new FileWriter("helloworld.txt");//这里也可以写绝对路径。fw.write("abc");}catch(IOException e){      System.out.println("error"+e.toString());}finally{if(fw!=null){   try{    fw.close();   }catch(IOException e){   System.out.println("close"+e.toString());   }}}}}

原创粉丝点击