顶一下,请大家帮帮忙,提点建议

解决方案 »

  1.   

    程序写的差不多,只要加上charset就行了。import java.io.RandomAccessFile;
    public class TestRead { public static void main(String[] args) {   //todo:测试以二进制方式读文件,先测试读二进制文件.
      try
      {
    RandomAccessFile in = new RandomAccessFile("c:\\test.JPG", "r");
    byte[] result = new byte[(int)in.length()];
    in.readFully(result);
    System.out.println(String.valueOf((int)in.length()));
    System.out.println(String.valueOf(result.length));
      //  in.close();
    String strTmp =new  String(result, "ISO-8859-1");
    System.out.println(String.valueOf(strTmp.length()));
    //   System.out.println(strTmp);
    System.out.println("in.length"+in.length());
    byte[] result1 = new byte[(int)in.length()];
    result1 = strTmp.getBytes("ISO-8859-1");
    RandomAccessFile inOut = new RandomAccessFile("c:\\test1.JPG", "rw");
    inOut.write(result1);
    System.out.println(String.valueOf(result1.length));      
    in.close();
    inOut.close();
          
    System.out.println("ok,just copy complete");
    //in.read(result);   }
      catch(Exception ex)
      {   }
    }
    }