BlogJava 聯系 聚合 管理  

          Blog Stats

          隨筆檔案

          exams


          java世界

          世界Java

          #

               摘要: 一:需要包含的包
            
            import java.security.*;
            import java.io.*;
            import java.util.*;
            import java.security.*;
            import java.security.cert.*;
            import sun.security.x509.*
            import java.security.cert.Certificate;
            import java.security.cert.CertificateFactory;  閱讀全文
          posted @ 2007-08-16 15:31 java2java 閱讀(1056) | 評論 (0)編輯 收藏

          Java的IO操作都是基于流進行操作的,為了提高讀寫效率一般需要進行緩沖。

          簡單的示例程序如下:

          /**
          * 讀出1.txt中的內容,寫入2.txt中
          *
          */

          import java.io.*;

          public class ReadWriteFile{
          public static void main(String[] args){
          try{

          File read = new File("c:\\1.txt");
          File write = new File("c:\\2.txt");

          BufferedReader br = new BufferedReader(
          new FileReader(read));
          BufferedWriter bw = new BufferedWriter(
          new FileWriter(write));
          String temp = null;
          temp = br.readLine();
          while(temp != null){
          //寫文件
          bw.write(temp + "\r\n"); //只適用Windows系統
          //繼續讀文件
          temp = br.readLine();
          }

          bw.close();
          br.close();

          }catch(FileNotFoundException e){ //文件未找到
          System.out.println (e);
          }catch(IOException e){
          System.out.println (e);
          }
          }
          }

          posted @ 2007-08-16 15:24 java2java 閱讀(263) | 評論 (0)編輯 收藏

          僅列出標題
          共5頁: 上一頁 1 2 3 4 5 
          主站蜘蛛池模板: 宁都县| 阿图什市| 平定县| 鸡泽县| 寻甸| 阿坝县| 陆丰市| 靖州| 锡林浩特市| 隆尧县| 泰州市| 蓝山县| 防城港市| 阿图什市| 青冈县| 凭祥市| 巧家县| 溆浦县| 方城县| 弋阳县| 吴川市| 东丰县| 达尔| 武汉市| 繁峙县| 房山区| 卢氏县| 澎湖县| 荣成市| 会理县| 鱼台县| 湘西| 浏阳市| 阜城县| 米脂县| 太湖县| 越西县| 澄江县| 墨竹工卡县| 郓城县| 绍兴县|