/** * 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); }
protected abstract <T extends SaveFileFormat> T create(SERIALIZER serializer, DATA data, Class<T> saveFileFormatClass);
protected abstract <T extends SaveFileFormat> T create(SERIALIZER serializer, DATA data, Class<T> saveFileFormatClass);
/** * 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); }