数据 aaaaaa存在e:\abc.txt中怎么把它读入程序,并且复制给字符串data,请给出源程序。谢了

解决方案 »

  1.   

    以前写的 你再改改http://blog.csdn.net/zqfddqr/article/details/7311646
      

  2.   

    what?String fileName = "e:\\abc.tx";
    RandomAcessFile raf = new RandomAccessFile(fileName, "r");
    String data = raf.readLine();
    raf.close();
      

  3.   

     /** 
         * 读取文件 
         * @param path 文件路径 
         * @return     数据数组 
         */ 
    这不有注释么
      

  4.   


    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    public class Test { public static void main(String[] args) throws Exception{

    FileInputStream fis = new FileInputStream(new File("e:/abc.txt"));
    BufferedInputStream bis = new BufferedInputStream(fis);
    String date = "";

    byte[] buff = new byte[1024];
    int length = 0;
    StringBuilder sb = new StringBuilder();
    while(-1 != (length = bis.read(buff))){
    sb.append(new String(buff,0,length));
    }
    date = sb.toString();
    System.out.println(date);
    }
    }