public Savable load(URL f) throws IOException { return load(f, null); }
public Savable load(File f) throws IOException { return load(f, null); }
public Savable load(InputStream is, ReadListener listener) throws IOException { return load(is, listener, null); }
public Savable load(InputStream is) throws IOException { return load(is, null, null); }
public Savable load(File f, ReadListener listener) throws IOException { FileInputStream fis = new FileInputStream(f); try { return load(fis, listener); } finally { fis.close(); } }
public Savable load(URL f, ReadListener listener) throws IOException { InputStream is = f.openStream(); Savable rVal = load(is, listener); is.close(); return rVal; }
public Savable load(byte[] data) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(data); Savable rVal = load(bais); bais.close(); return rVal; }
@Override public Object load(final AssetInfo assetInfo) throws IOException { BinaryImporter importer = importers.pollLast(); if (importer == null) { importer = new BinaryImporter(); } try { return importer.load(assetInfo); } finally { importers.addLast(importer); } } }
@Override @SuppressWarnings("unchecked") public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException { BufferInputStream in = new BufferInputStream(data); Savable s = importer.load(in); in.close(); return (T) s; }
public Object load(AssetInfo info){ // if (!(info.getKey() instanceof ModelKey)) // throw new IllegalArgumentException("Model assets must be loaded using a ModelKey"); assetManager = info.getManager(); InputStream is = null; try { is = info.openStream(); Savable s = load(is); return s; } catch (IOException ex) { logger.log(Level.SEVERE, "An error occured while loading jME binary object", ex); } finally { if (is != null){ try { is.close(); } catch (IOException ex) {} } } return null; }
imp.setAssetManager(manager); sav = imp.load(is); Logger.getLogger(SaveGame.class.getName()).log(Level.FINE, "Loading data from: {0}", file.getAbsolutePath()); } catch (IOException ex) {
/** * Saves the object into memory then loads it from memory. * * Used by tests to check if the persistence system is working. * * @param <T> The type of savable. * @param assetManager AssetManager to load assets from. * @param object The object to save and then load. * @return A new instance that has been saved and loaded from the * original object. */ public static <T extends Savable> T saveAndLoad(AssetManager assetManager, T object) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { BinaryExporter exporter = new BinaryExporter(); exporter.save(object, baos); BinaryImporter importer = new BinaryImporter(); importer.setAssetManager(assetManager); return (T) importer.load(baos.toByteArray()); } catch (IOException ex) { // Should never happen. throw new AssertionError(ex); } }
BinaryImporter imp = BinaryImporter.getInstance(); imp.setAssetManager(assetManager); terrain = (TerrainQuad) imp.load(new BufferedInputStream(fis)); rootNode.attachChild((Node)terrain);
@Override public void simpleInitApp() { Spatial ogreModel = assetManager.loadModel("Models/Oto/Oto.mesh.xml"); DirectionalLight dl = new DirectionalLight(); dl.setColor(ColorRGBA.White); dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal()); rootNode.addLight(dl); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); BinaryExporter exp = new BinaryExporter(); exp.save(ogreModel, baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); BinaryImporter imp = new BinaryImporter(); imp.setAssetManager(assetManager); Node ogreModelReloaded = (Node) imp.load(bais, null, null); AnimComposer composer = ogreModelReloaded.getControl(AnimComposer.class); composer.setCurrentAction("Walk"); rootNode.attachChild(ogreModelReloaded); } catch (IOException ex){ ex.printStackTrace(); } } }
BinaryImporter imp=BinaryImporter.getInstance(); imp.setAssetManager(assetManager); Node newLoaderNode=(Node)imp.load(bin);
BinaryImporter imp=BinaryImporter.getInstance(); imp.setAssetManager(assetManager); Node newPhysicsRootNode=(Node)imp.load(bin);
public Savable load(byte[] data) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(data); Savable rVal = load(bais); bais.close(); return rVal; }
public Savable load(File f, ReadListener listener) throws IOException { FileInputStream fis = new FileInputStream(f); Savable rVal = load(fis, listener); fis.close(); return rVal; }
@Override @SuppressWarnings("unchecked") public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException { BufferInputStream in = new BufferInputStream(data); Savable s = importer.load(in); in.close(); return (T) s; }
@Override @SuppressWarnings("unchecked") public <T> T readObject(ByteBuffer data, Class<T> c) throws IOException { BufferInputStream in = new BufferInputStream(data); Savable s = importer.load(in); in.close(); return (T) s; }