/** Returns a writer for writing to this file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public Writer writer (boolean append) { return writer(append, null); }
/** Returns a writer for writing to this file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public Writer writer (boolean append) { return writer(append, null); }
/** Writes the specified string to the file using the specified charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param charset May be null to use the default charset. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeString (String string, boolean append, String charset) { Writer writer = null; try { writer = writer(append, charset); writer.write(string); } catch (Exception ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(writer); } }
/** Writes the specified string to the file using the specified charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param charset May be null to use the default charset. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeString (String string, boolean append, String charset) { Writer writer = null; try { writer = writer(append, charset); writer.write(string); } catch (Exception ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(writer); } }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Class elementType, FileHandle file) { Writer writer = null; try { writer = file.writer(false, "UTF-8"); toJson(object, knownType, elementType, writer); } catch (Exception ex) { throw new SerializationException("Error writing file: " + file, ex); } finally { StreamUtils.closeQuietly(writer); } }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Class elementType, FileHandle file) { Writer writer = null; try { writer = file.writer(false, "UTF-8"); toJson(object, knownType, elementType, writer); } catch (Exception ex) { throw new SerializationException("Error writing file: " + file, ex); } finally { StreamUtils.closeQuietly(writer); } }
Writer writer = file.writer(false); int index = 0; for (Page page : packer.pages) {
Writer writer = file.writer(false); int index = 0; for (Page page : packer.pages) {
/** Returns a writer for writing to this file using the default charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public Writer writer (boolean append) { return writer(append, null); }
public boolean saveToFile(String fileName) { FileHandle fileHandle = Gdx.files.local(fileName + ".txt"); BufferedWriter bw = new BufferedWriter(fileHandle.writer(false)); try { bw.append("stuff"); } catch (IOException e) { e.printStackTrace(); return false; } finally { try { bw.close(); } catch (IOException e) { e.printStackTrace(); } } return true; }
/** Writes the specified string to the file using the specified charset. Parent directories will be created if necessary. * @param append If false, this file will be overwritten if it exists, otherwise it will be appended. * @param charset May be null to use the default charset. * @throws GdxRuntimeException if this file handle represents a directory, if it is a {@link FileType#Classpath} or * {@link FileType#Internal} file, or if it could not be written. */ public void writeString (String string, boolean append, String charset) { Writer writer = null; try { writer = writer(append, charset); writer.write(string); } catch (Exception ex) { throw new GdxRuntimeException("Error writing file: " + file + " (" + type + ")", ex); } finally { StreamUtils.closeQuietly(writer); } }
/** @param knownType May be null if the type is unknown. * @param elementType May be null if the type is unknown. */ public void toJson (Object object, Class knownType, Class elementType, FileHandle file) { Writer writer = null; try { writer = file.writer(false, "UTF-8"); toJson(object, knownType, elementType, writer); } catch (Exception ex) { throw new SerializationException("Error writing file: " + file, ex); } finally { StreamUtils.closeQuietly(writer); } }
public static void saveDtdSchema(final LmlParser lmlParser, final FileHandle file) { try { final Writer appendable = file.writer(false, "UTF-8"); final boolean strict = lmlParser.isStrict(); lmlParser.setStrict(false); // Temporary setting to non-strict to generate as much tags as possible. Dtd.saveSchema(lmlParser, appendable); appendable.close(); lmlParser.setStrict(strict); } catch (final Exception exception) { throw new GdxRuntimeException("Unable to save DTD schema.", exception); } } }
public void save() { Json json = new Json(); // String s = json.prettyPrint(list); String s = json.toJson(list, ArrayList.class, TimeVerb.class); s = json.prettyPrint(s); Writer w = EngineAssetManager.getInstance().getUserFile(fileName + RECORD_EXT).writer(false, "UTF-8"); try { w.write(s); w.close(); } catch (IOException e) { EngineLogger.error("ERROR SAVING RECORD", e); } } }
Writer writer = file.writer(false); int index = 0; for (Page page : packer.pages) {
public void saveModel(String chapterId) throws IOException { EngineLogger.debug("SAVING GAME MODEL"); if (w.isDisposed()) return; Json json = new BladeJson(w, Mode.MODEL); json.setOutputType(OutputType.javascript); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer w = EngineAssetManager.getInstance().getModelFile(chapterId + EngineAssetManager.CHAPTER_EXT) .writer(false, "UTF-8"); try { w.write(s); w.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING MODEL", e); } finally { w.close(); } }
public void saveGameState(String filename, boolean screenshot) throws IOException { EngineLogger.debug("SAVING GAME STATE"); if (w.isDisposed()) return; Json json = new BladeJson(w, Mode.STATE); json.setOutputType(OutputType.javascript); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(this); else s = json.toJson(this); Writer writer = EngineAssetManager.getInstance().getUserFile(filename).writer(false, "UTF-8"); try { writer.write(s); writer.flush(); } catch (IOException e) { throw new IOException("ERROR SAVING GAME", e); } finally { writer.close(); } // Save Screenshot if (screenshot) w.takeScreenshot(filename + ".png", SCREENSHOT_DEFAULT_WIDTH); }
public void saveWorldDesc(FileHandle file) throws IOException { float scale = EngineAssetManager.getInstance().getScale(); Json json = new BladeJson(w, Mode.MODEL); json.setOutputType(OutputType.javascript); json.setWriter(new StringWriter()); json.writeObjectStart(); json.writeValue("width", w.getWidth() / scale); json.writeValue("height", w.getHeight() / scale); json.writeValue("initChapter", w.getInitChapter()); w.getVerbManager().write(json); json.writeObjectEnd(); String s = null; if (EngineLogger.debugMode()) s = json.prettyPrint(json.getWriter().getWriter().toString()); else s = json.getWriter().getWriter().toString(); Writer w = file.writer(false, "UTF-8"); w.write(s); w.close(); }