/** * Loads data from an InputStream (usually a file) and provides a SaveFileFormat (or subclass) * object that contains the deserialized data. */ public <T extends SaveFileFormat> T load(InputStream is, Class<T> format) { if (alwaysLoadStreamMemory || !InputStreamHelper.isMarkSupported(is)) { try { byte[] buf = byteBuffer(); ByteArrayOutputStream baos = byteArrayOutputStream(); int read; while ((read = is.read(buf)) != -1) { baos.write(buf, 0, read); } is = new ByteArrayInputStream(baos.toByteArray()); } catch (IOException e) { throw new RuntimeException("Error copying inputstream", e); } } return backend.load(is, format); }
public void save(OutputStream out, SaveFileFormat format) throws SerializationException { if (backend == null) { throw new RuntimeException("Missing ArtemisSerializer, see #setBackend."); } world.inject(format); backend.save(out, format); }
/** * Loads data from an InputStream (usually a file) and provides a SaveFileFormat (or subclass) * object that contains the deserialized data. */ public <T extends SaveFileFormat> T load(InputStream is, Class<T> format) { if (alwaysLoadStreamMemory || !InputStreamHelper.isMarkSupported(is)) { try { byte[] buf = byteBuffer(); ByteArrayOutputStream baos = byteArrayOutputStream(); int read; while ((read = is.read(buf)) != -1) { baos.write(buf, 0, read); } is = new ByteArrayInputStream(baos.toByteArray()); } catch (IOException e) { throw new RuntimeException("Error copying inputstream", e); } } return backend.load(is, format); }
public void save(OutputStream out, SaveFileFormat format) throws SerializationException { if (backend == null) { throw new RuntimeException("Missing ArtemisSerializer, see #setBackend."); } world.inject(format); backend.save(out, format); }
/** * Convenience method for immediately serializing a group of entities with the default * SaveFileFormat. For finer control or SaveFileFormat subclasses, use #save. */ protected final void save(OutputStream out, IntBag entities) { save(out, new SaveFileFormat(entities)); }
/** * Convenience method for immediately serializing a group of entities with the default * SaveFileFormat. For finer control or SaveFileFormat subclasses, use #save. */ protected final void save(OutputStream out, IntBag entities) { save(out, new SaveFileFormat(entities)); }