假设serialise.bin是一个文件,是满语的,被一个ArrayList时,它是序列化反序列化文件,然后将内容存储在ArrayList <String>中。 (JAVA)
public static ArrayList<String> deserialise(){
ArrayList<String> words= new ArrayList<String>();
File serial = new File("serialise.bin");
try(ObjectInputStream in = new ObjectInputStream(new FileInputStream(serial))){
System.out.println(in.readObject()); //prints out the content
//I want to store the content in to an ArrayList<String>
}catch(Exception e){
e.getMessage();
}
return words;
}
我希望能够deserialise了“serialise.bin”文件和存储内容在一个ArrayList
你的问题是什么?你的代码有问题吗? – shmosel
不要返回'ArrayList'。相反,返回List,这样'deserialise'的调用者就不会依赖于那个实现细节。 –