use of java.io.LineNumberReader in project camel by apache.
the class ConnectorModel method loadFile.
private static List<String> loadFile(InputStream fis) throws Exception {
List<String> lines = new ArrayList<>();
LineNumberReader reader = new LineNumberReader(new InputStreamReader(fis));
String line;
do {
line = reader.readLine();
if (line != null) {
lines.add(line);
}
} while (line != null);
reader.close();
return lines;
}
use of java.io.LineNumberReader in project hazelcast by hazelcast.
the class MapWordCountAggregationPerformanceTest method fillMapWithDataEachLineNewEntry.
private static void fillMapWithDataEachLineNewEntry(HazelcastInstance hazelcastInstance) throws Exception {
IMap<String, String> map = hazelcastInstance.getMap(MAP_NAME);
for (String file : DATA_RESOURCES_TO_LOAD) {
InputStream is = MapWordCountAggregationPerformanceTest.class.getResourceAsStream("/wordcount/" + file);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(is));
int batchSize = 10000;
int batchSizeCount = 0;
Map<String, String> batch = new HashMap<String, String>(batchSize);
String line;
while ((line = reader.readLine()) != null) {
batch.put(UuidUtil.newSecureUuidString(), line);
batchSizeCount++;
if (batchSizeCount == batchSize) {
map.putAll(batch);
batchSizeCount = 0;
batch.clear();
}
}
if (batchSizeCount > 0) {
map.putAll(batch);
batch.clear();
}
is.close();
reader.close();
}
}
use of java.io.LineNumberReader in project hazelcast by hazelcast.
the class MapWordCountAggregationPerformanceTest method fillMapWithData.
private static void fillMapWithData(HazelcastInstance hazelcastInstance) throws Exception {
IMap<String, String> map = hazelcastInstance.getMap(MAP_NAME);
for (String file : DATA_RESOURCES_TO_LOAD) {
InputStream is = MapWordCountAggregationPerformanceTest.class.getResourceAsStream("/wordcount/" + file);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(is));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
map.put(UuidUtil.newSecureUuidString(), sb.toString());
is.close();
reader.close();
}
}
use of java.io.LineNumberReader in project gephi by gephi.
the class ImporterDOT method execute.
@Override
public boolean execute(ContainerLoader container) {
this.container = container;
this.report = new Report();
LineNumberReader lineReader = ImportUtils.getTextReader(reader);
try {
importData(lineReader);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
lineReader.close();
} catch (IOException ex) {
}
}
return !cancel;
}
use of java.io.LineNumberReader in project gephi by gephi.
the class ImporterGDF method execute.
@Override
public boolean execute(ContainerLoader container) {
this.container = container;
this.report = new Report();
LineNumberReader lineReader = ImportUtils.getTextReader(reader);
try {
importData(lineReader);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
try {
lineReader.close();
} catch (IOException ex) {
}
}
return !cancel;
}
Aggregations