Seltsam, wo ich es doch im ersten Post bereits beschrieben habe.
Java:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public class ArrayIO<T>
{
private static final ArrayIO<int[][]> INSTANCE = new ArrayIO<int[][]>();
private ArrayIO()
{
super();
}
public void save(T array, File f)
{
try
{
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(f));
oos.writeObject(array);
oos.flush();
oos.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public T load(File f)
{
T array = null;
try
{
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
array = (T) ois.readObject();
ois.close();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
}
return(array);
}
public static ArrayIO<int[][]> getInstance()
{
return(INSTANCE);
}
}
Zuletzt bearbeitet: