java.lang.Object
io.jenetics.util.IO
Class for object serialization. The following example shows how to write and
reload a given population.
// Creating result population.
EvolutionResult<DoubleGene, Double> result = stream
.collect(toBestEvolutionResult());
// Writing the population to disk.
final File file = new File("population.bin");
IO.object.write(result.getPopulation(), file);
// Reading the population from disk.
ISeq<Phenotype<G, C>> population = (ISeq<Phenotype<G, C>>)IO.object.read(file);
EvolutionStream<DoubleGene, Double> stream = Engine
.build(ff, gtf)
.stream(population, 1);
- Since:
- 1.0
- Version:
- 4.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfromByteArray(byte[] bytes) Creates a, previously serialized, object from the givenbyte[]array.Reads an object from the given file.read(InputStream in) Reads an object from the given input stream.<T> TReads an object from the given file.abstract <T> Tread(Class<T> type, InputStream in) Reads an object from the given input stream.<T> TReads an object from the given file.<T> TReads an object from the given file.Reads an object from the given file.Reads an object from the given file.byte[]toByteArray(Object object) Serializes the givenobjectto abyte[]array.voidWrite the (serializable) object to the given file.abstract voidwrite(Object object, OutputStream out) Write the (serializable) object to the given output stream.voidWrite the (serializable) object to the given path.voidWrite the (serializable) object to the given path.
-
Field Details
-
object
IO implementation for "native" Java serialization.
-
-
Constructor Details
-
IO
protected IO()
-
-
Method Details
-
toByteArray
Serializes the givenobjectto abyte[]array.- Parameters:
object- the object to serialize.- Returns:
- the serialized
objectasbyte[]array - Throws:
NullPointerException- if one of the objects isnull.IOException- if the object could not be serialized.- Since:
- 4.1
-
write
Write the (serializable) object to the given path.- Parameters:
object- the object to serialize.path- the path to write the object to.- Throws:
NullPointerException- if one of the arguments isnull.IOException- if the object could not be serialized.
-
write
Write the (serializable) object to the given path.- Parameters:
object- the object to serialize.path- the path to write the object to.- Throws:
NullPointerException- if one of the arguments isnull.IOException- if the object could not be serialized.
-
write
Write the (serializable) object to the given file.- Parameters:
object- the object to serialize.file- the file to write the object to.- Throws:
NullPointerException- if one of the arguments isnull.IOException- if the object could not be serialized.
-
write
Write the (serializable) object to the given output stream.- Parameters:
object- the object to serialize.out- the output stream to write the object to.- Throws:
NullPointerException- if one of the arguments isnull.IOException- if the object could not be serialized.
-
fromByteArray
Creates a, previously serialized, object from the givenbyte[]array.- Parameters:
bytes- the serialized object.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the inputbytesisnull.IOException- if the object could not be deserialized.- Since:
- 4.1
-
read
Reads an object from the given file.- Type Parameters:
T- the type of the read object- Parameters:
type- the type of the read object.path- the path to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given file.- Parameters:
path- the path to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given file.- Type Parameters:
T- the type of the read object- Parameters:
type- the type of the read object.path- the path to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given file.- Parameters:
path- the path to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given file.- Type Parameters:
T- the type of the read object- Parameters:
type- the type of the read object.file- the file to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given file.- Parameters:
file- the file to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given input stream.- Type Parameters:
T- the type of the read object- Parameters:
type- the type of the read object.in- the input stream to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-
read
Reads an object from the given input stream.- Parameters:
in- the input stream to read from.- Returns:
- the deserialized object.
- Throws:
NullPointerException- if the input streaminisnull.IOException- if the object could not be read.
-