我刚才在csdn里粘贴的,愿赐教

解决方案 »

  1.   

    : bluerain2002(蓝雨灰天) 
    :( 我也有相同的问题,老解决不了。
    efly(易飞) 你是水货,不懂就别搀和
    关注
      

  2.   

    唉,,,以上代码windows下绝对没问题,就世unix下出错
      

  3.   

    看你想读什么,文本的,二进制的?怎么读?随机的?顺序的?关键看你想解决什么问题。这个是最重要的。YOU 二位 SEE?
    只有知道了做什么,才能找到BEST SOLUTION。
      

  4.   

    真心求解。以上方法一种顺序,一种随机啊。二进制的没多大问题,主要是
    较大一点的文本文件,居然莫名其妙的掉个把字符,也是在windows下没问题,unix下出问题。
      

  5.   

    这个问题我好象也遇到过,不是JAVA的问题.是UNIX下的文本文件跟WINDOWS下的文本文件的结构好象不太一样.好象UNIX下的文本文件每一行的换行符是\r
    而WINDOS下是\r\n.记不太清了,看看有没有帮助吧.
      

  6.   

    abstract class GeneralFace implements WHtmTag { abstract String getDocument(String tempFile, String[] replacements); public void getDocument(
    String tempFile,
    String docFile,
    String[] replacements) {
    setFileContent(docFile, getDocument(tempFile, replacements));
    } protected String getFileContent(String filePath) {
    String str_ret = "";
    String line = null;
    //Read file  
    try {
    FileReader fr = new FileReader(filePath);
    BufferedReader br = new BufferedReader(fr);
    while ((line = br.readLine()) != null) {
    str_ret += line + "\r\n";
    }
    br.close();
    fr.close();
    } catch (FileNotFoundException fnfe) {
    System.out.println("File_not_found");
    } catch (IOException ioe) {
    System.out.println("IO_reading_error");
    }
    return str_ret;
    } protected void setFileContent(String filePath, String content) {
    try {
    FileWriter fw = new FileWriter(filePath);
    BufferedWriter bw = new BufferedWriter(fw);
    bw.write(content);
    bw.flush();
    bw.close();
    fw.close();
    } catch (IOException ioe) {
    System.out.println("IO_writing_error");
    }
    }}读文本你试试,看有多长的文本它读不出来?这个是在linux环境下写的。window 下照样通过。