public static List<Name> readBbgTickers(String pFilePath, Names<Name> pCache) throws IOException { File tFile = new File(pFilePath); if (tFile.isDirectory()) { return readBbgTickersDir(pFilePath, pCache); } BufferedReader tReader = new BufferedReader(new FileReader(pFilePath)); List<String> tAllLines = new ArrayList<String>(); String tLine; while ((tLine = tReader.readLine()) != null) { tLine = tLine.trim(); if (tLine.equals("")) { continue; } if (!tAllLines.contains(tLine)) { tAllLines.add(tLine); } } tReader.close(); List<Name> tNames = new ArrayList<Name>(); for (String tTicker : tAllLines) { StringTokenizer tSt = new StringTokenizer(tTicker, " "); String tId = tSt.nextToken(); Name tName = pCache.queryId(tId); if (tName == null) { tName = new Name(tId); tName.addId(tTicker, Bbg.Constants.BBG); pCache.addName(tName); } tNames.add(tName); } return tNames; }
private static List<Name> readWithHeaderInternal(File tFile, Names<Name> pCache) throws IOException { if (!tFile.isFile()) { throw new RuntimeException("not a file: " + tFile.getAbsolutePath()); } List<Name> tNames = new ArrayList<Name>(); BufferedReader tReader = new BufferedReader(new FileReader(tFile)); String[] tHdr = tReader.readLine().split("\t"); String tLine; while ((tLine = tReader.readLine()) != null) { tLine = tLine.trim(); if (tLine.equals("")) { continue; } String[] tIds = tLine.split("\t"); Name tName = pCache.queryId(tIds[0]); if (tName == null) { tName = new Name(tIds[0]); for (int i = 1; i < tHdr.length; i++) { tName.addId(tIds[i], tHdr[i]); } pCache.addName(tName); } tNames.add(tName); } tReader.close(); return tNames; }