如题

解决方案 »

  1.   

    RandomAccessFile accessFile=new RandomAccessFile("f:/t.txt","rw");
    accessFile.write("中文".getBytes());
    accessFile.close();
      

  2.   

    RandomAccessFile raf = new RandomAccessFile(logfile, "rw");
         raf.writeBytes("errorTime is " + exceptionDate + "  errorClassName is " +
                          className +
                          "\n errorException is " + e.toString().getBytes() + "\n");
         raf.close();e是个Exception
      

  3.   

    getP.createLog(new Exception("出口报文缴费金额不符合缴费标准!"),"GJFret");
      

  4.   

    你试试这样行不行
    raf.write(("errorTime is " + exceptionDate + " errorClassName is " +
    className +
    "\n errorException is " + e.toString() + "\n").getBytes());
      

  5.   

    是编码问题RandomAccessFile accessFile=new RandomAccessFile("f:/t.txt","rw");
    accessFile.write("中文".getBytes("UTF-8"););
    accessFile.close();
      

  6.   

    如果你的输出文件是乱码,而不是????? 的话
    也可以在2000/XP下,用记事本打开,结果就出现了2000/XP下,记事本是支持多种编码的可见问题出在编码上
      

  7.   

    我说的编码有两层意思,
    1。你的源文件的编码
    2。你的输出文件的编码RandomAccessFile accessFile=new RandomAccessFile("f:/t.txt","rw");
    accessFile.write("中文".getBytes("UTF-8"););
    accessFile.close();用这个程序时,你先要确保你的源文件的编码支持中文,不要用ANSI,
    我用的是UTF-8
      

  8.   

    既然输出的是文本信息,为什么要用 RandomAccessFile 呢?RandomAccessFile 更适合用来读写“二进制”的内容,因为你在读写一串文本的时候,很难保证起始的字节不在“半个汉字”上。