最简单的方法,
class A
{
    string[][] a;
}//write
                ByteArrayOutputStream buf =  new ByteArrayOutputStream();
                ObjectOutputStream o = new ObjectOutputStream(buf);
                o.writeObject(s.property);
//read 
                ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
                A aa = (A)in.readObject();

解决方案 »

  1.   

    一不小心把我的代码写出来了.
    o.writeObject(s.property)=>o.writeObject(a)
      

  2.   

    to cming:
    thank you.
    I will try.
    呆会给分,嘿嘿
      

  3.   

    String[][] testArray={{"asdasD",aasdad"},{"asdsad",asdsad"},{"dfgfdg","asdasd"}};
                 try{ByteArrayOutputStream buf =  new ByteArrayOutputStream();
                    ObjectOutputStream o = new ObjectOutputStream(buf);
                    o.writeObject(testArray);
                    FileOutputStream fout=new FileOutputStream("D:\\array.txt");
                    buf.writeTo(fout);
                    fout.flush();
                    fout.close();}
                    catch(Exception ex){}
    执行这段代码后,
    很不幸,输出以后是段乱码,怎么办啊?有其他方法吗?
      

  4.   

    你这样写不对.
    o.writeObject(a);是写对象进去,是不可读的.不是写一个string[][];
    你要写写text到file.不用这样做. 
      

  5.   

    这个原因啊,但是我必须返回ByteArrayOutputStream类型的
      

  6.   

    用o.writeChars(String);来写.分成n个一唯依此写进去.
      

  7.   

    呵呵,谢了。不过我有方便的方法了。
    String[][] testArray={{"asdasD",aasdad"},{"asdsad",asdsad"},{"dfgfdg","asdasd"}};
        ByteArrayOutputStream byteArray=new ByteArrayOutputStream();
        for(int i=0;i<3;i++){
          for(int j=0;j<2;j++)
            try{
              byteArray.write(testArray[i][j].getBytes());
            }
            catch(Exception ex){}
    终于写进去了,如何,呵呵。