Package java.io

Examples of java.io.File


    long thID = Thread.currentThread().getId();
    long CPUStartTime=-1, trainCPUTimeElapsed=-1, testCPUTimeElapsed=-1,
         trainTimeStart, trainTimeElapsed, testTimeStart, testTimeElapsed;   
   
    String costName = train.relationName() + CostMatrix.FILE_EXTENSION;
    File costFile = new File(getOnDemandDirectory(), costName);
    if (!costFile.exists()) {
      throw new Exception("On-demand cost file doesn't exist: " + costFile);
    }
    CostMatrix costMatrix = new CostMatrix(new BufferedReader(
    new FileReader(costFile)));
   
View Full Code Here


  }

  protected void setupFileChooser() {
    if (m_fileChooser == null) {
      m_fileChooser =
        new JFileChooser(new File(System.getProperty("user.dir")));
    }

    m_fileChooser.addChoosableFileFilter(m_binaryFilter);
    if (KOML.isPresent()) {
      m_fileChooser.addChoosableFileFilter(m_KOMLFilter);
View Full Code Here

        // i.e. after de-serialization
        setupFileChooser();
      }
      int returnVal = m_fileChooser.showOpenDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File loadFrom = m_fileChooser.getSelectedFile();

        // add extension if necessary
        if (m_fileChooser.getFileFilter() == m_binaryFilter) {
          if (!loadFrom.getName().toLowerCase().endsWith("." + FILE_EXTENSION)) {
            loadFrom = new File(loadFrom.getParent(),
                                loadFrom.getName() + "." + FILE_EXTENSION);
          }
        } else if (m_fileChooser.getFileFilter() == m_KOMLFilter) {
          if (!loadFrom.getName().toLowerCase().endsWith(KOML.FILE_EXTENSION
                                                         + FILE_EXTENSION)) {
            loadFrom = new File(loadFrom.getParent(),
                                loadFrom.getName() + KOML.FILE_EXTENSION
                                + FILE_EXTENSION);
          }
        } else if (m_fileChooser.getFileFilter() == m_XStreamFilter) {
          if (!loadFrom.getName().toLowerCase().endsWith(XStream.FILE_EXTENSION
                                                        + FILE_EXTENSION)) {
            loadFrom = new File(loadFrom.getParent(),
                                loadFrom.getName() + XStream.FILE_EXTENSION
                                + FILE_EXTENSION);
          }
        }

        weka.classifiers.Classifier temp = null;
        Instances tempHeader = null;
        // KOML ?
        if ((KOML.isPresent()) &&
            (loadFrom.getAbsolutePath().toLowerCase().
             endsWith(KOML.FILE_EXTENSION + FILE_EXTENSION))) {
          Vector v = (Vector) KOML.read(loadFrom.getAbsolutePath());
          temp = (weka.classifiers.Classifier) v.elementAt(0);
          if (v.size() == 2) {
            // try and grab the header
            tempHeader = (Instances) v.elementAt(1);
          }
        } /* XStream */ else if ((XStream.isPresent()) &&
                                 (loadFrom.getAbsolutePath().toLowerCase().
                                  endsWith(XStream.FILE_EXTENSION + FILE_EXTENSION))) {
          Vector v = (Vector) XStream.read(loadFrom.getAbsolutePath());
          temp = (weka.classifiers.Classifier) v.elementAt(0);
          if (v.size() == 2) {
            // try and grab the header
            tempHeader = (Instances) v.elementAt(1);
          }
View Full Code Here

        // i.e. after de-serialization
        setupFileChooser();
      }
      int returnVal = m_fileChooser.showSaveDialog(this);
      if (returnVal == JFileChooser.APPROVE_OPTION) {
        File saveTo = m_fileChooser.getSelectedFile();
        String fn = saveTo.getAbsolutePath();
        if (m_fileChooser.getFileFilter() == m_binaryFilter) {
          if (!fn.toLowerCase().endsWith("." + FILE_EXTENSION)) {
            fn += "." + FILE_EXTENSION;
          }
        } else if (m_fileChooser.getFileFilter() == m_KOMLFilter) {
          if (!fn.toLowerCase().endsWith(KOML.FILE_EXTENSION + FILE_EXTENSION)) {
            fn += KOML.FILE_EXTENSION + FILE_EXTENSION;
          }
        } else if (m_fileChooser.getFileFilter() == m_XStreamFilter) {
          if (!fn.toLowerCase().endsWith(XStream.FILE_EXTENSION + FILE_EXTENSION)) {
            fn += XStream.FILE_EXTENSION + FILE_EXTENSION;
          }
        }
        saveTo = new File(fn);

        // now serialize model
        // KOML?
        if ((KOML.isPresent()) &&
            saveTo.getAbsolutePath().toLowerCase().
            endsWith(KOML.FILE_EXTENSION + FILE_EXTENSION)) {
          SerializedModelSaver.saveKOML(saveTo,
                                        m_Classifier,
                                        (m_trainingSet != null)
                                        ? new Instances(m_trainingSet, 0)
                                        : null);
          /*          Vector v = new Vector();
          v.add(m_Classifier);
          if (m_trainingSet != null) {
            v.add(new Instances(m_trainingSet, 0));
          }
          v.trimToSize();
          KOML.write(saveTo.getAbsolutePath(), v); */
        } /* XStream */ else if ((XStream.isPresent()) &&
                                 saveTo.getAbsolutePath().toLowerCase().
            endsWith(XStream.FILE_EXTENSION + FILE_EXTENSION)) {

          SerializedModelSaver.saveXStream(saveTo,
                                           m_Classifier,
                                           (m_trainingSet != null)
View Full Code Here

  public FileEnvironmentField(String label) {
    super(label);
   
    m_fileEditor.addPropertyChangeListener(new PropertyChangeListener() {
      public void propertyChange(PropertyChangeEvent evt) {
        File selected = (File)m_fileEditor.getValue();
        if (selected != null) {
          FileEnvironmentField.this.setText(selected.toString());
        }       
      }
    });
   
    final JFileChooser embeddedEditor = (JFileChooser)m_fileEditor.getCustomEditor();
    embeddedEditor.setFileSelectionMode(JFileChooser.FILES_ONLY);
    ExtensionFileFilter ff =
      new ExtensionFileFilter(".model", "Serialized Weka classifier (*.model)");
    embeddedEditor.addChoosableFileFilter(ff);   
   
    m_browseBut = new JButton("Browse...");
    m_browseBut.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        try {
          String modelPath = getText();
          if (modelPath != null) {
            try {
              modelPath = m_env.substitute(modelPath);
            } catch (Exception ex) {             
            }
           
            File toSet = new File(modelPath);           
            if (toSet.isFile()) {
              m_fileEditor.setValue(new File(modelPath));
              toSet = toSet.getParentFile();             
            }
            if (toSet.isDirectory()) {
              embeddedEditor.setCurrentDirectory(toSet);
            }
          }
         
          showFileEditor();
View Full Code Here

    /**
     * Start the standalone (in process) database.
     */
    private void startStandaloneDatabase() throws Exception
    {
        final File h2Dir = checkDataDir() ;
              
        dbPath = new File(h2Dir, name);
       
        final String dbURL = JDBC_URL_PREFIX + dbPath.toURI().toString() + flags ;
        log.info(dbURL);
       
        // Check we have connectivity
View Full Code Here

     * Start a remote/server database
     * @throws Exception
     */
    private void startRemoteDatabase() throws Exception
    {
        final File h2Dir = checkDataDir() ;
        dbPath = new File(h2Dir, name);
      
        // Start DB in new thread, or else it will block us
        serverThread = new Thread("h2-" + name)
        {
            public void run()
View Full Code Here

     * @throws IOException For errors checking/creating the h2 data directory.
     */
    private File checkDataDir() throws IOException
    {
        // Get the server data directory
        final File dataDir = getDataDir();

        // Get DB directory
        final File h2Dir = new File(dataDir, H2_DATA_DIR);

        if (!h2Dir.exists())
        {
            h2Dir.mkdirs();
        }
        else if (!h2Dir.isDirectory())
        {
            throw new IOException("Failed to create directory: " + h2Dir);
        }
        return h2Dir ;
    }
View Full Code Here

            //return serverConfig.getServerDataDir();
          org.jboss.soa.dsp.server.ServerConfig serverConfig=
            org.jboss.soa.bpel.runtime.JBossDSPFactory.getServerConfig();
          return(serverConfig.getServerDeployDir());
        }
        return new File(datadir);
    }
View Full Code Here

    String szSuffix = "JPG";
    if (szFile.contains(".")) {
      int nSuffix = szFile.lastIndexOf('.');
      szSuffix = szFile.substring(nSuffix + 1);
    }
    File f = new File(szFile);
    try {
      ImageIO.write(im, szSuffix, f);
    } catch (IOException ex) {
     
    }
View Full Code Here

TOP

Related Classes of java.io.File

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.