def read(filePath): bytes = Files.readAllBytes(filePath) content = StringUtil.fromBytes(bytes) if content.find(Strings.FileUtils_separator) != -1: (vars, script) = content.split(Strings.FileUtils_separator, 2) return (vars, script) else: return (None, None)
def readJsonFile(self, filePath=None): fp = Paths.get(filePath) jsonStr = Files.readAllBytes(fp) return self.deserFromJson(jsonStr)
return result.copyTo(new float[1][nlabels])[0]; } } } private static int maxIndex(float[] probabilities) { int best = 0; for (int i = 1; i < probabilities.length; ++i) { if (probabilities[i] > probabilities[best]) { best = i; } } return best; } private static byte[] readAllBytesOrExit(Path path) { try { return Files.readAllBytes(path); } catch (IOException e) { System.err.println("Failed to read [" + path + "]: " + e.getMessage()); System.exit(1); } return null; } private static List<String> readAllLinesOrExit(Path path) { try { return Files.readAllLines(path, Charset.forName("UTF-8")); } catch (IOException e) { System.err.println("Failed to read [" + path + "]: " + e.getMessage()); System.exit(0); } return null; }
def readJsonFile (self, filePath = None): fp = Paths.get(filePath); jsonStr = Files.readAllBytes(fp); return self.deserFromJson(jsonStr)