List of usage examples for java.io LineNumberReader LineNumberReader
public LineNumberReader(Reader in)
From source file:com.l2jfree.gameserver.datatables.StaticObjects.java
private void parseData() { LineNumberReader lnr = null;/* w w w. j ava 2s . c o m*/ try { File doorData = new File(Config.DATAPACK_ROOT, "data/staticobjects.csv"); lnr = new LineNumberReader(new BufferedReader(new FileReader(doorData))); String line = null; while ((line = lnr.readLine()) != null) { if (line.trim().length() == 0 || line.startsWith("#")) continue; L2StaticObjectInstance obj = parse(line); _staticObjects.put(obj.getStaticObjectId(), obj); } } catch (FileNotFoundException e) { _log.warn("staticobjects.csv is missing in data folder"); } catch (Exception e) { _log.warn("error while creating StaticObjects table", e); } finally { try { if (lnr != null) lnr.close(); } catch (Exception e) { } } }
From source file:eu.fbk.utils.analysis.stemmer.AbstractStemmer.java
/** * Stems a list of terms read from the specified reader. * * @param r the reader/*www . ja v a 2s. c o m*/ */ public void process(Reader r) throws IOException { long begin = 0, end = 0, time = 0; int count = 0; LineNumberReader lnr = new LineNumberReader(r); String line = null; String s = null; while ((line = lnr.readLine()) != null) { begin = System.nanoTime(); s = stem(line); end = System.nanoTime(); time += end - begin; count++; } // end while lnr.close(); logger.info(count + " total " + df.format(time) + " ns"); logger.info("avg " + df.format((double) time / count) + " ns"); }
From source file:org.locationtech.jtstest.util.StringUtil.java
public static String getStackTrace(Throwable t, int depth) { String stackTrace = ""; StringReader stringReader = new StringReader(getStackTrace(t)); LineNumberReader lineNumberReader = new LineNumberReader(stringReader); for (int i = 0; i < depth; i++) { try {//from w w w . j a v a 2 s . c o m stackTrace += lineNumberReader.readLine() + newLine; } catch (IOException e) { Assert.shouldNeverReachHere(); } } return stackTrace; }
From source file:org.apache.axis.security.simple.SimpleSecurityProvider.java
private synchronized void initialize(MessageContext msgContext) { if (initialized) return;//from w w w. jav a 2s .c om String configPath = msgContext.getStrProp(Constants.MC_CONFIGPATH); if (configPath == null) { configPath = ""; } else { configPath += File.separator; } File userFile = new File(configPath + "users.lst"); if (userFile.exists()) { users = new HashMap(); try { FileReader fr = new FileReader(userFile); LineNumberReader lnr = new LineNumberReader(fr); String line = null; // parse lines into user and passwd tokens and add result to hash table while ((line = lnr.readLine()) != null) { StringTokenizer st = new StringTokenizer(line); if (st.hasMoreTokens()) { String userID = st.nextToken(); String passwd = (st.hasMoreTokens()) ? st.nextToken() : ""; if (log.isDebugEnabled()) { log.debug(Messages.getMessage("fromFile00", userID, passwd)); } users.put(userID, passwd); } } lnr.close(); } catch (Exception e) { log.error(Messages.getMessage("exception00"), e); return; } } initialized = true; }
From source file:org.kalypso.model.wspm.ewawi.data.reader.AbstractEwawiReader.java
public void read(final File file) throws IOException, ParseException { try (LineNumberReader reader = new LineNumberReader(new FileReader(file))) { m_data.setSourceFile(file);//w w w . j av a 2 s. c o m read(reader); } }
From source file:gemlite.core.internal.mq.receiver.file.FileReceiver.java
@Override public void connect() { try {// w w w. j a va2s .c om lr = new LineNumberReader( new InputStreamReader(new FileInputStream(param.fileName), param.fileEncoding)); line = readLine(); } catch (UnsupportedEncodingException | FileNotFoundException e) { LogUtil.getMqSyncLog().error(param.fileName, e); throw new MqReceiveException(true); } }
From source file:edu.stanford.muse.index.NEROld.java
public static void readLocationsFreebase() throws IOException { InputStream is = new GZIPInputStream(NER.class.getClassLoader().getResourceAsStream("locations.gz")); LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is, "UTF-8")); while (true) { String line = lnr.readLine(); if (line == null) break; StringTokenizer st = new StringTokenizer(line, "\t"); if (st.countTokens() == 3) { String locationName = st.nextToken(); String canonicalName = locationName.toLowerCase(); String lat = st.nextToken(); String longi = st.nextToken(); locations.put(canonicalName, new LocationInfo(locationName, lat, longi)); }//from w ww.java2 s . c om } }
From source file:com.l2jfree.gameserver.instancemanager.BoatManager.java
private final void load() { if (!Config.ALLOW_BOAT) { return;/*from w w w . ja va 2s. c o m*/ } LineNumberReader lnr = null; try { File doorData = new File(Config.DATAPACK_ROOT, "data/boat.csv"); lnr = new LineNumberReader(new BufferedReader(new FileReader(doorData))); String line = null; while ((line = lnr.readLine()) != null) { if (line.trim().length() == 0 || line.startsWith("#")) continue; L2BoatInstance boat = parseLine(line); boat.spawn(); _staticItems.put(boat.getObjectId(), boat); if (_log.isDebugEnabled()) { _log.info("Boat ID : " + boat.getObjectId()); } } } catch (FileNotFoundException e) { _log.warn("boat.csv is missing in data folder"); } catch (Exception e) { _log.warn("error while creating boat table ", e); } finally { IOUtils.closeQuietly(lnr); } }
From source file:gemlite.core.internal.testing.processor.file.TFileReceiver.java
@Override public void connect() { try {/*from www .j a va2 s .c o m*/ lr = new LineNumberReader( new InputStreamReader(new FileInputStream(param.fileName), param.fileEncoding)); //line = readLine(); } catch (UnsupportedEncodingException | FileNotFoundException e) { LogUtil.getMqSyncLog().error(param.fileName, e); throw new MqReceiveException(true); } }
From source file:de.langmi.spring.batch.examples.complex.file.split.GetLineCountTasklet.java
/** * Short variant to get the line count of the file, there can be problems with files where * the last line has no content.// w ww. ja v a2 s.co m * * @param file * @param chunkContext * @return the line count * @throws IOException * @throws FileNotFoundException */ private int getLineCount(File file) throws IOException, FileNotFoundException { LineNumberReader lnr = null; try { lnr = new LineNumberReader(new FileReader(file)); String line = null; int count = 0; while ((line = lnr.readLine()) != null) { count = lnr.getLineNumber(); } return count; } finally { if (lnr != null) { lnr.close(); } } }