private void applyLabel(String inPointsFile, String outPointsFile, List<String> symbols) { System.out.println("Applying labels for points file: " + inPointsFile); FileReader input; BufferedWriter bufWriter = null; try { FileOutputStream fos = new FileOutputStream(outPointsFile); bufWriter = new BufferedWriter(new OutputStreamWriter(fos)); File inFile = new File(inPointsFile); if (!inFile.exists()) { System.out.println("ERROR: In file doens't exist"); return; } input = new FileReader(inPointsFile); BufferedReader bufRead = new BufferedReader(input); String inputLine; int index = 0; while ((inputLine = bufRead.readLine()) != null && index < symbols.size()) { Point p = Utils.readPoint(inputLine); String symbol = symbols.get(index); int clazz = 0; if (this.invertedFixedClases.containsKey(symbol)) { clazz = this.invertedFixedClases.get(symbol); } else { // get the corresponding symbol // get the class for this one String sector = invertedSectors.get(symbol); if (sector != null) { clazz = sectorToClazz.get(sector); } else { // System.out.println("No sector: " + symbol); } } p.setClazz(clazz); String s = p.serialize(); bufWriter.write(s); bufWriter.newLine(); index++; } System.out.println("Read lines: " + index); } catch (Exception e) { throw new RuntimeException("Failed to read/write file", e); } finally { if (bufWriter != null) { try { bufWriter.close(); } catch (IOException ignore) { } } } }