當前位置: 首頁>>代碼示例>>Java>>正文


Java Utils.convertToRelativePath方法代碼示例

本文整理匯總了Java中weka.core.Utils.convertToRelativePath方法的典型用法代碼示例。如果您正苦於以下問題:Java Utils.convertToRelativePath方法的具體用法?Java Utils.convertToRelativePath怎麽用?Java Utils.convertToRelativePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在weka.core.Utils的用法示例。


在下文中一共展示了Utils.convertToRelativePath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setDirectory

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * Set the directory that the model(s) will be saved into.
 * 
 * @param d the directory to save to
 */
public void setDirectory(File d) {
  m_directory = d;
  if (m_useRelativePath) {
    try {
      m_directory = Utils.convertToRelativePath(m_directory);
    } catch (Exception ex) {
    }
  }
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:15,代碼來源:SerializedModelSaver.java

示例2: setSource

import weka.core.Utils; //導入方法依賴的package包/類
/**
 * Resets the Loader object and sets the source of the data set to be the
 * supplied File object.
 * 
 * @param file the source file.
 * @throws IOException if an error occurs
 */
@Override
public void setSource(File file) throws IOException {
  File original = file;
  m_structure = null;

  setRetrieval(NONE);

  if (file == null) {
    throw new IOException("Source file object is null!");
  }

  // try {
  String fName = file.getPath();
  try {
    if (m_env == null) {
      m_env = Environment.getSystemWide();
    }
    fName = m_env.substitute(fName);
  } catch (Exception e) {
    // ignore any missing environment variables at this time
    // as it is possible that these may be set by the time
    // the actual file is processed

    // throw new IOException(e.getMessage());
  }
  file = new File(fName);
  // set the source only if the file exists
  if (file.exists() && file.isFile()) {
    if (file.getName().endsWith(
      getFileExtension() + FILE_EXTENSION_COMPRESSED)) {
      setSource(new GZIPInputStream(new FileInputStream(file)));
    } else {
      setSource(new FileInputStream(file));
    }
  } else {
    // System.out.println("Looking in classpath....");
    // look for it as a resource in the classpath

    // forward slashes are platform independent for loading from the
    // classpath...
    String fnameWithCorrectSeparators = fName
      .replace(File.separatorChar, '/');
    if (this.getClass().getClassLoader()
      .getResource(fnameWithCorrectSeparators) != null) {
      // System.out.println("Found resource in classpath...");
      setSource(this.getClass().getClassLoader()
        .getResourceAsStream(fnameWithCorrectSeparators));
    }
  }
  // }
  /*
   * catch (FileNotFoundException ex) { throw new
   * IOException("File not found"); }
   */

  if (m_useRelativePath) {
    try {
      m_sourceFile = Utils.convertToRelativePath(original);
      m_File = m_sourceFile.getPath();
    } catch (Exception ex) {
      // System.err.println("[AbstractFileLoader] can't convert path to relative path.");
      m_sourceFile = original;
      m_File = m_sourceFile.getPath();
    }
  } else {
    m_sourceFile = original;
    m_File = m_sourceFile.getPath();
  }
}
 
開發者ID:mydzigear,項目名稱:repo.kmeanspp.silhouette_score,代碼行數:77,代碼來源:AbstractFileLoader.java


注:本文中的weka.core.Utils.convertToRelativePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。