public static StageConfiguration load(Gson gson, Node file) throws IOException { try (Reader reader = file.newReader()) { return gson.fromJson(reader, StageConfiguration.class); } }
/** Reads properties with the encoding for this node */ public Properties readProperties() throws IOException { Properties p; try (Reader src = newReader()) { p = new Properties(); p.load(src); } return p; }
public LineReader newLineReader(LineFormat format) throws IOException { return new LineReader(newReader(), format); }
public <T> Instance<T> loadXml(Node node) throws IOException, LoaderException { // TODO: use stream instead!? try (Reader src = node.newReader()) { return loadXml(node.getUri().toString(), src); } }
/** @return false when netrc does not exist */ public boolean loadNetRcOpt() throws IOException { Node src; src = home.join(".netrc"); try (Reader reader = src.newReader()) { netRc.parse(reader); return true; } catch (net.oneandone.sushi.fs.FileNotFoundException e) { return false; } } }
public Object[] run(net.oneandone.sushi.fs.Node node) throws IOException { return run(node.toString(), node.newReader()); }
public static Csv read(Format format, Node node) throws IOException { StringBuilder msg; Csv csv; String line; try (Reader orig = node.newReader(); LineReader src = new LineReader(orig, new LineFormat(LineFormat.GENERIC_SEPARATOR, LineFormat.Trim.SEPARATOR))) { csv = new Csv(format); msg = new StringBuilder(); while (true) { line = src.next(); if (line == null) { if (msg.length() > 0) { throw new CsvExceptions(msg.toString()); } return csv; } try { csv.add(line); } catch (CsvLineException e) { if (msg.length() > 0) { msg.append('\n'); } msg.append(src.toString()).append(":").append(src.getLine()).append(": ").append(e.getMessage()); } } } }