use of uk.ac.sussex.gdsc.core.utils.UnicodeReader in project GDSC-SMLM by aherbert.
the class PeakResultsReader method readRapidStorm.
private MemoryPeakResults readRapidStorm() {
final MemoryPeakResults results = createResults();
results.setName(FileUtils.getName(filename));
try (FileInputStream fis = new FileInputStream(filename);
BufferedReader input = new BufferedReader(new UnicodeReader(fis, null))) {
final ProgressReporter reporter = createProgressReporter(fis);
String line;
int errors = 0;
// Skip the header
while ((line = input.readLine()) != null) {
if (line.isEmpty()) {
continue;
}
if (line.charAt(0) != '#') {
// This is the first record
if (!addRapidStormResult(results, line)) {
errors = 1;
}
break;
}
}
while ((line = input.readLine()) != null) {
if (line.isEmpty() || line.charAt(0) == '#') {
continue;
}
if (!addRapidStormResult(results, line) && ++errors >= 10) {
break;
}
reporter.showProgress();
}
} catch (final IOException ex) {
logError(ex);
}
return results;
}
use of uk.ac.sussex.gdsc.core.utils.UnicodeReader in project GDSC-SMLM by aherbert.
the class PeakResultsReader method getHeader.
/**
* Gets the header from the results file.
*
* @return The header from the results file
*/
public String getHeader() {
if (header == null) {
try (BufferedReader input = new BufferedReader(new UnicodeReader(new FileInputStream(filename), null))) {
final StringBuilder sb = new StringBuilder();
String line;
int count = 0;
while ((line = input.readLine()) != null) {
count++;
if (count == 1) {
// line
if (line.startsWith("Channel Name")) {
sb.append(line).append('\n');
break;
}
// User may try and load the text saved directly from the ImageJ Table Results
if (line.contains(IMAGEJ_TABLE_RESULTS_HEADER_V1_V2)) {
sb.append(line).append('\n');
break;
}
}
if (line.isEmpty()) {
continue;
}
if (line.charAt(0) == '#') {
sb.append(line).append('\n');
} else {
break;
}
}
header = sb.toString();
version = getField("FileVersion");
format = FileFormat.UNKNOWN;
if (!guessFormatFromVersion()) {
guessFormat(line);
}
} catch (final IOException ex) {
logError(ex);
}
}
return header;
}
Aggregations