如果有各种类型数据,按顺序读入,按顺序读出,怎么保证进去的是什么样出来的也是什么样呢是之前处理好,全部转换成某种类型的数组读到文件中,再读出反过来处理
还是用什么其它方法?

解决方案 »

  1.   

    Yes, you're right! If it's an Object, read it as an Object; if it's an int variable, read it as an int.
      

  2.   

    建议你可以使用DataInputStream 和 DataOutputStream ,然后套接FileInputStream ,FileOutputStream,即可实现不同数据类型的读入,读出;建议看下DataInputStream的API,有很多针对基本类型的输入方法
      

  3.   

    那么应该怎么处理我上面说到的情况呢import java.io.*;public class test{
    public static void main(String[] args){
    try{
    byte count=0;;
    byte a[]=new byte[10];
    for(byte i:a) i=count++;
    OutputStream m=new FileOutputStream("E:/1.txt");
    m.write(a);
    System.out.println(a);

    InputStream n=new FileInputStream("E:/1.txt");
    byte b[]=new byte[10];
    n.read(b);
    System.out.println(b);
    }

    catch(Exception e)
    {
    System.out.println(e);
    }
    }

    }怎么结果是这个,两个结果不一样?
    [B@11b86e7
    [B@35ce36