/** * tries to determine the saver to use for this kind of file, returns null if * none can be found. * * @param file the file to return a converter for * @return the converter if one was found, null otherwise */ public static AbstractFileSaver getSaverForFile(File file) { return getSaverForFile(file.getAbsolutePath()); }
/** * tries to determine the saver to use for this kind of file, returns null if * none can be found. * * @param file the file to return a converter for * @return the converter if one was found, null otherwise */ public static AbstractFileSaver getSaverForFile(File file) { return getSaverForFile(file.getAbsolutePath()); }
/** * initializes the sink to save the data to the given file. * * @param filename the file to save data to * @throws Exception if set of saver fails */ public DataSink(String filename) throws Exception { m_Stream = null; if (DataSource.isArff(filename)) { m_Saver = new ArffSaver(); } else { m_Saver = getSaverForFile(filename); } ((AbstractFileSaver) m_Saver).setFile(new File(filename)); }
/** * Saves the data to the specified file. * * @param file the file to save the data to * @param saver the saver to use, determines it automatically if null */ public void save(File file, AbstractFileSaver saver) { if (saver == null) saver = ConverterUtils.getSaverForFile(file); try { saver.setFile(file); saver.writeBatch(); m_CurrentFile = file; } catch (Exception e) { System.err.println("Failed to save data to '" + file + "':"); e.printStackTrace(); JOptionPane.showMessageDialog( this, "Failed to save dataset to '" + file + "':\n" + e, "Error saving", JOptionPane.ERROR_MESSAGE); } updateMenu(); }
/** * initializes the sink to save the data to the given file. * * @param filename the file to save data to * @throws Exception if set of saver fails */ public DataSink(String filename) throws Exception { m_Stream = null; if (DataSource.isArff(filename)) { m_Saver = new ArffSaver(); } else { m_Saver = getSaverForFile(filename); } ((AbstractFileSaver) m_Saver).setFile(new File(filename)); }
m_CurrentConverter = ConverterUtils.getLoaderForFile(filename); } else if (dialogType == SAVER_DIALOG) { m_CurrentConverter = ConverterUtils.getSaverForFile(filename); } else { throw new IllegalStateException("Cannot determine loader/saver!");
m_CurrentConverter = ConverterUtils.getLoaderForFile(filename); } else if (dialogType == SAVER_DIALOG) { m_CurrentConverter = ConverterUtils.getSaverForFile(filename); } else { throw new IllegalStateException("Cannot determine loader/saver!");
if (m_sFile != null && !m_sFile.equals("")) { AbstractFileSaver saver = ConverterUtils .getSaverForFile(m_sFile);
if (m_sFile != null && !m_sFile.equals("")) { AbstractFileSaver saver = ConverterUtils .getSaverForFile(m_sFile);
/** * saves the current data into a file */ public void saveFile() { ArffPanel panel; String filename; AbstractSaver saver; // no panel? -> exit panel = getCurrentPanel(); if (panel == null) { return; } filename = panel.getFilename(); if (filename.equals(ArffPanel.TAB_INSTANCES)) { saveFileAs(); } else { saver = ConverterUtils.getSaverForFile(filename); try { saver.setFile(new File(filename)); saver.setInstances(panel.getInstances()); saver.writeBatch(); panel.setChanged(false); setCurrentFilename(filename); } catch (Exception e) { e.printStackTrace(); } } }
/** * saves the current data into a file */ public void saveFile() { DataPanel panel; String filename; AbstractSaver saver; // no panel? -> exit panel = getCurrentPanel(); if (panel == null) { return; } filename = panel.getFilename(); if (filename.equals(DataPanel.TAB_INSTANCES)) { saveFileAs(); } else { saver = ConverterUtils.getSaverForFile(filename); try { saver.setFile(new File(filename)); saver.setInstances(panel.getInstances()); saver.writeBatch(); panel.setChanged(false); setCurrentFilename(filename); } catch (Exception e) { e.printStackTrace(); } } }
/** * saves the current data into a file */ public void saveFile() { ArffPanel panel; String filename; AbstractSaver saver; // no panel? -> exit panel = getCurrentPanel(); if (panel == null) { return; } filename = panel.getFilename(); if (filename.equals(ArffPanel.TAB_INSTANCES)) { saveFileAs(); } else { saver = ConverterUtils.getSaverForFile(filename); try { saver.setFile(new File(filename)); saver.setInstances(panel.getInstances()); saver.writeBatch(); panel.setChanged(false); setCurrentFilename(filename); } catch (Exception e) { e.printStackTrace(); } } }
/** * saves the current data into a file */ public void saveFile() { DataPanel panel; String filename; AbstractSaver saver; // no panel? -> exit panel = getCurrentPanel(); if (panel == null) { return; } filename = panel.getFilename(); if (filename.equals(DataPanel.TAB_INSTANCES)) { saveFileAs(); } else { saver = ConverterUtils.getSaverForFile(filename); try { saver.setFile(new File(filename)); saver.setInstances(panel.getInstances()); saver.writeBatch(); panel.setChanged(false); setCurrentFilename(filename); } catch (Exception e) { e.printStackTrace(); } } }
/** * Saves the data to the specified file. * * @param file the file to save the data to * @param saver the saver to use, determines it automatically if null */ public void save(File file, AbstractFileSaver saver) { if (saver == null) saver = ConverterUtils.getSaverForFile(file); try { log(null, "Saving: " + file); saver.setInstances(m_Data); if ((saver.retrieveFile() == null) || !saver.retrieveFile().equals(file)) saver.setFile(file); saver.writeBatch(); m_CurrentFile = file; log(null, "Saved successfully: " + file); } catch (Exception e) { handleException(null, "Failed to save data to '" + file + "':", e); JOptionPane.showMessageDialog( this, "Failed to save dataset to '" + file + "':\n" + e, "Error saving", JOptionPane.ERROR_MESSAGE); } updateMenu(); }
"File was modified - save changes?"); if (result == JOptionPane.YES_OPTION) { Saver saver = ConverterUtils.getSaverForFile(filename); saver.setFile(new File(filename)); saver.setInstances(dialog.getInstances());
/** * Saves the data to the specified file. * * @param file the file to save the data to * @param saver the saver to use, determines it automatically if null */ public void save(File file, AbstractFileSaver saver) { if (saver == null) saver = ConverterUtils.getSaverForFile(file); try { log(null, "Saving: " + file); saver.setInstances(m_Data); if ((saver.retrieveFile() == null) || !saver.retrieveFile().equals(file)) saver.setFile(file); saver.writeBatch(); m_CurrentFile = file; log(null, "Saved successfully: " + file); } catch (Exception e) { handleException(null, "Failed to save data to '" + file + "':", e); JOptionPane.showMessageDialog( this, "Failed to save dataset to '" + file + "':\n" + e, "Error saving", JOptionPane.ERROR_MESSAGE); } updateMenu(); }
predicted.add(predInst); AbstractFileSaver saver = ConverterUtils.getSaverForFile(predictions); if (saver == null) { System.err.println("Failed to determine saver for '" + predictions + "', using " + ArffSaver.class.getName());
predicted.add(predInst); AbstractFileSaver saver = ConverterUtils.getSaverForFile(predictions); if (saver == null) { System.err.println("Failed to determine saver for '" + predictions + "', using " + ArffSaver.class.getName());
AbstractFileSaver saver = ConverterUtils.getSaverForFile(predictions); if (saver == null) { System.err.println("Failed to determine saver for '" + predictions + "', using " + ArffSaver.class.getName());
AbstractFileSaver saver = ConverterUtils.getSaverForFile(predictions); if (saver == null) { System.err.println("Failed to determine saver for '" + predictions + "', using " + ArffSaver.class.getName());