求一个方法,把文件(.jpg.txt.rar等)转化为byte[],
public byte[] convert(String file) {
   file = "c:\1.jpg";}
另一个方法,再把byte[] copy成新的文件public void convert(byte[] b,String file) {
   file = "c:\2.jpg";}

解决方案 »

  1.   

    你可以用RandomAccessFile去读取你想要转化的文件..
    你也可以用RandomAccessFile将byte[]写入你需要写入的文件爱你
      

  2.   

    就用InputStream和OutputStream就行了,给你一个简单的示意,不能运行:InputStream in = new FileInputStream(file1);
    in.read(bytes);OutputStream out = new FileOutputStream(file2);
    out.write(bytes);
      

  3.   

    这样原文件 bytes大小不知道,生成新文件的时候也不能确定大小,
    请问什么方法,可以保持和原文件 一样大小呢