logger.log(Level.SEVERE,
"Could not create a new temporary file ", e);
return true;
}
Task newTask = null;
if (extension.equals("mzdata")) {
newTask = new MzDataReadTask(temp, newMZmineFile);
}
if (extension.equals("mzxml")) {
newTask = new MzXMLReadTask(temp, newMZmineFile);
}
if (extension.equals("mzml")) {
newTask = new MzMLReadTask(temp, newMZmineFile);
}
if (extension.equals("cdf")) {
newTask = new NetCDFReadTask(temp, newMZmineFile);
}
if (extension.equals("raw")) {
newTask = new XcaliburRawFileReadTask(temp, newMZmineFile);
}
if (extension.equals("csv")) {
newTask = new AgilentCsvReadTask(temp, newMZmineFile);
}
if (extension.equals("xml"))
try {
// Check the first 512 bytes of the file, to determine
// the
// file type
FileReader reader = new FileReader(temp);
char buffer[] = new char[512];
reader.read(buffer);
reader.close();
String fileHeader = new String(buffer);
if (fileHeader.contains("mzXML")) {
newTask = new MzXMLReadTask(temp, newMZmineFile);
}
if (fileHeader.contains("mzData")) {
newTask = new MzDataReadTask(temp, newMZmineFile);
}
if (fileHeader.contains("mzML")) {
newTask = new MzMLReadTask(temp, newMZmineFile);
}
} catch (Exception e) {
logger.warning("Cannot read file " + temp + ": " + e);
return true;
}
if (newTask == null) {
logger.severe("Cannot determine file type of file " + temp);
MZmineCore.getDesktop().displayErrorMessage(
"Obtained malformed sample file for \"" + sampleID
+ '"');
return true;
}
newTask.addTaskListener(this);
tasks.add(newTask);
} catch (FileNotFoundException e) {
logger.severe("Could not find expected sample \"" + sampleID
+ '"');
MZmineCore.getDesktop().displayErrorMessage(