public Element parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public Element parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public JsonValue parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public JsonValue parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
protected ObjectMap<String, String> parse (final FileHandle file) { ObjectMap<String, String> result = new ObjectMap<String, String>(); BufferedReader reader = file.reader(1024); String line; String snipName = ""; stringBuilder.setLength(0); int idx; try { while ((line = reader.readLine()) != null) { if (line.length() > 3 && line.charAt(0) == '[' && (idx = line.indexOf(']')) > 1) { if (snipName.length() > 0 || stringBuilder.length() > 0) result.put(snipName, stringBuilder.toString()); stringBuilder.setLength(0); snipName = line.substring(1, idx); } else stringBuilder.append(line.trim()).append("\r\n"); } } catch (IOException e) { throw new GdxRuntimeException(e); } if (snipName.length() > 0 || stringBuilder.length() > 0) result.put(snipName, stringBuilder.toString()); return result; }
BufferedReader reader = file.reader(256); try { while (true) {
BufferedReader reader = file.reader(256); try { while (true) {
/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */ @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, PolygonRegionParameters params) { if (params == null) params = defaultParameters; String image = null; try { BufferedReader reader = file.reader(params.readerBuffer); for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) { image = line.substring(params.texturePrefix.length()); break; } reader.close(); } catch (IOException e) { throw new GdxRuntimeException("Error reading " + fileName, e); } if (image == null && params.textureExtensions != null) for (String extension : params.textureExtensions) { FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension)); if (sibling.exists()) image = sibling.name(); } if (image != null) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1); deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class)); return deps; } return null; }
/** If the PSH file contains a line starting with {@link PolygonRegionParameters#texturePrefix params.texturePrefix}, an * {@link AssetDescriptor} for the file referenced on that line will be added to the returned Array. Otherwise a sibling of the * given file with the same name and the first found extension in {@link PolygonRegionParameters#textureExtensions * params.textureExtensions} will be used. If no suitable file is found, the returned Array will be empty. */ @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, PolygonRegionParameters params) { if (params == null) params = defaultParameters; String image = null; try { BufferedReader reader = file.reader(params.readerBuffer); for (String line = reader.readLine(); line != null; line = reader.readLine()) if (line.startsWith(params.texturePrefix)) { image = line.substring(params.texturePrefix.length()); break; } reader.close(); } catch (IOException e) { throw new GdxRuntimeException("Error reading " + fileName, e); } if (image == null && params.textureExtensions != null) for (String extension : params.textureExtensions) { FileHandle sibling = file.sibling(file.nameWithoutExtension().concat("." + extension)); if (sibling.exists()) image = sibling.name(); } if (image != null) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(1); deps.add(new AssetDescriptor<Texture>(file.sibling(image), Texture.class)); return deps; } return null; }
private static I18NBundle loadBundle (FileHandle baseFileHandle, String encoding, Locale targetLocale) { I18NBundle bundle = null; Reader reader = null; try { FileHandle fileHandle = toFileHandle(baseFileHandle, targetLocale); if (checkFileExistence(fileHandle)) { // Instantiate the bundle bundle = new I18NBundle(); // Load bundle properties from the stream with the specified encoding reader = fileHandle.reader(encoding); bundle.load(reader); } } catch (IOException e) { throw new GdxRuntimeException(e); } finally { StreamUtils.closeQuietly(reader); } if (bundle != null) { bundle.setLocale(targetLocale); } return bundle; }
private static I18NBundle loadBundle (FileHandle baseFileHandle, String encoding, Locale targetLocale) { I18NBundle bundle = null; Reader reader = null; try { FileHandle fileHandle = toFileHandle(baseFileHandle, targetLocale); if (checkFileExistence(fileHandle)) { // Instantiate the bundle bundle = new I18NBundle(); // Load bundle properties from the stream with the specified encoding reader = fileHandle.reader(encoding); bundle.load(reader); } } catch (IOException e) { throw new GdxRuntimeException(e); } finally { StreamUtils.closeQuietly(reader); } if (bundle != null) { bundle.setLocale(targetLocale); } return bundle; }
/** Parses the given file. * @param file the file * @throws SerializationException if the file cannot be successfully parsed. */ public void parse (FileHandle file) { try { parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
@SuppressWarnings("unchecked") @Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, BehaviorTreeParameter parameter) { this.behaviorTree = null; Object blackboard = null; BehaviorTreeParser parser = null; if (parameter != null) { blackboard = parameter.blackboard; parser = parameter.parser; } if (parser == null) parser = new BehaviorTreeParser(); Reader reader = null; try { reader = file.reader(); this.behaviorTree = parser.parse(reader, blackboard); } finally { StreamUtils.closeQuietly(reader); } }
public static void load() { config = new Properties(); try { config.load(EngineAssetManager.getInstance().getAsset(PROPERTIES_FILENAME).reader()); } catch (Exception e) { EngineLogger.error("ERROR LOADING PROPERTIES: " + e.getMessage()); } }
public JsonValue parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public Element parse (FileHandle file) { try { return parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public Array<Shortcut> parse(FileHandle fileHandle) { BufferedReader br = null; try { br = new BufferedReader(fileHandle.reader()); return parse(br); } catch (IOException | GdxRuntimeException e) { Gdx.app.error(TAG, "Error reading shortcut file", e); return new Array<>(); } finally { if (br != null) try { br.close(); } catch (IOException ignore) { } } }
/** Parses the given file. * @param file the file * @throws SerializationException if the file cannot be successfully parsed. */ public void parse (FileHandle file) { try { parse(file.reader("UTF-8")); } catch (Exception ex) { throw new SerializationException("Error parsing file: " + file, ex); } }
public void loadGameState(FileHandle savedFile) throws IOException { EngineLogger.debug("LOADING GAME STATE"); if (savedFile.exists()) { JsonValue root = new JsonReader().parse(savedFile.reader("UTF-8")); Json json = new BladeJson(w, Mode.STATE); json.setIgnoreUnknownFields(true); read(json, root); } else { throw new IOException("LOADGAMESTATE: no saved game exists"); } }
public Configuration() { map = new ObjectMap<String, String>(); FileHandle file = Gdx.files.internal("lw.properties"); if (file.exists()) { Reader reader = file.reader("utf-8"); try { PropertiesUtils.load(map, reader); } catch (Exception e) { throw new GdxRuntimeException(e); } finally { StreamUtils.closeQuietly(reader); } } }