Example usage for java.io File getAbsoluteFile

List of usage examples for java.io File getAbsoluteFile

Introduction

In this page you can find the example usage for java.io File getAbsoluteFile.

Prototype

public File getAbsoluteFile() 

Source Link

Document

Returns the absolute form of this abstract pathname.

Usage

From source file:myLexTo.ReadConfig.java

public Hashtable read() {
    Hashtable config = new Hashtable();

    try {// w  w w.  j av  a  2 s.co m
        File f = new File(System.getProperty("java.class.path"));
        File dir = f.getAbsoluteFile().getParentFile();

        String path = dir.getParent().toString();
        String configFile = path + "/config.json";

        JSONTokener jsonTokener = new JSONTokener(new FileReader(path + "/config.json"));
        JSONArray arrobj = new JSONArray(jsonTokener);

        for (int i = 0; i < arrobj.length(); i++) {
            JSONObject item = arrobj.getJSONObject(i);
            String lexitron = item.getString("lexitron");
            String herblist = item.getString("herblist");
            String properties = item.getString("properties");
            String stopwords = item.getString("stopwords");
            String symptoms = item.getString("symptoms");

            config.put("lexitron", lexitron);
            config.put("herblist", herblist);
            config.put("properties", properties);
            config.put("stopwords", stopwords);
            config.put("symptoms", symptoms);
        }
    } catch (FileNotFoundException | JSONException ex) {
        Logger.getLogger(ReadConfig.class.getName()).log(Level.SEVERE, null, ex);
    }

    return config;
}

From source file:com.ieasy.basic.util.file.FileUtils.java

/**
 * ??/*w  w w . j a  v  a2s.  c  o m*/
 * 
 * @param filePath
 *            ??
 * @param definedName
 *            ??
 * @return
 */
public static boolean rename(String filePath, String definedName) {
    File file = new File(filePath);
    if (file.exists()) {
        String fileExt = file.getName().substring(file.getName().lastIndexOf(".") + 1).toLowerCase();

        String rename = file.getParent() + "/" + definedName + "." + fileExt;

        if (file.renameTo(new File(rename))) {
            logger.debug("???{} TO {}", file.getAbsoluteFile(), rename);
            return true;
        } else {
            logger.debug("??{} TO {}", file.getAbsoluteFile(),
                    rename);
            return false;
        }
    } else {
        logger.debug("?{}", file.getAbsoluteFile());
        return false;
    }
}

From source file:de.thischwa.pmcms.view.renderer.RenderData.java

public void addFile(final File file) {
    if (!file.isDirectory())
        files.add(file.getAbsoluteFile());
}

From source file:com.st.cms.utils.ACache.java

/**
 * mapkey+??id/*from   ww w . j  ava2  s.com*/
 * 
 * @param cacheDir
 * @param max_zise
 * @param max_count
 * @return
 */
public static ACache get(File cacheDir, long max_zise, int max_count) {
    // key+??idmapvaluemanager
    ACache manager = mInstanceMap.get(cacheDir.getAbsoluteFile() + myPid());
    if (manager == null) {// 
        manager = new ACache(cacheDir, max_zise, max_count);
        mInstanceMap.put(cacheDir.getAbsolutePath() + myPid(), manager);
    }
    return manager;
}

From source file:com.epam.wilma.stubconfig.cache.cleaner.helper.StubConfigPathProvider.java

/**
 * This method is dedicated for selecting files from the given cache folder with *_stubConfig.xml pattern.
 *
 * @param cachePath is the relative path of the cache folder
 * @return List&lt;String&gt; which contains paths of result files of the selecting.
 *//*from   ww w  . j av a  2 s . c  o m*/
public List<String> getConfigPathsFromCache(final String cachePath) {
    List<String> resultPaths = new ArrayList<>();
    File folder = new File(cachePath);
    folder = folder.getAbsoluteFile();
    for (File file : fileUtils.listFilesWithFilter(folder, "^[1-9]([0-9]*)_stubConfig.xml$")) {
        resultPaths.add(file.getPath());
    }
    return resultPaths;
}

From source file:net.nicholaswilliams.java.licensing.encryption.FilePublicKeyDataProvider.java

/**
 * Create a new provider, specifying the file from which the public key can be read.
 *
 * @param publicKeyFile the public key file
 *///from  w  w  w.  j  ava  2 s .co  m
public FilePublicKeyDataProvider(File publicKeyFile) {
    this.publicKeyFile = publicKeyFile.getAbsoluteFile();
}

From source file:net.nicholaswilliams.java.licensing.encryption.FilePrivateKeyDataProvider.java

/**
 * Create a new provider, specifying the file from which the private key can be read.
 *
 * @param privateKeyFile the private key file
 *//*from  ww w. jav  a  2 s . c  om*/
public FilePrivateKeyDataProvider(File privateKeyFile) {
    this.privateKeyFile = privateKeyFile.getAbsoluteFile();
}

From source file:nl.ordina.bag.etl.processor.MutatiesFileProcessor.java

protected void processMutatiesFile(String filename) throws FileNotFoundException, IOException {
    File file = new File(filename);
    logger.info("Processing file " + file.getAbsoluteFile() + " started");
    processMutatiesFile(new FileInputStream(file));
    logger.info("Processing file " + file.getAbsoluteFile() + " finished");
}

From source file:com.fusesource.forge.jmstest.peristence.ProbeAwarePeristenceAdapter.java

public void init() {
    super.init();

    File dbFile = new File(getFileName());

    if (!dbFile.getAbsoluteFile().getParentFile().exists()) {
        try {//from   www.j  a v  a2  s.co  m
            dbFile.getCanonicalFile().mkdirs();
        } catch (IOException e) {
            log().error("Error creating Rrd4j file.", e);
        }
    }

    if (dbFile.exists()) {
        dbFile.delete();
    }

    log().debug("Persistence Adapter uses : " + dbFile.getAbsolutePath());
}

From source file:com.epam.wilma.stubconfig.cache.cleaner.helper.StubConfigPathProvider.java

/**
 * This method provides the paths of selecting with the given pattern. This pattern is like endsWith.
 *
 * @param sourceFolderPath is the relative path of a folder
 * @param pattern          is a pattern, example: *something.xml -&gt; ABsomething.xml, Asomething.xml
 * @return List&lt;String&gt; which contains paths of result files of the selecting.
 *///from  ww  w.ja v a2 s  .com
public List<String> getConfigPathsFromSpecificFolder(final String sourceFolderPath, final String pattern) {
    List<String> resultPaths = new ArrayList<>();
    if (!pattern.contains("*")) {
        String specificFilePath;
        if ("".equals(sourceFolderPath)) {
            specificFilePath = pattern;
        } else {
            specificFilePath = FilenameUtils.separatorsToSystem(sourceFolderPath + "/" + pattern);
        }
        resultPaths.add(specificFilePath);
    } else {
        File folder = new File(sourceFolderPath);
        folder = folder.getAbsoluteFile();
        int cutFromHere = pattern.indexOf("*") + 1;
        String endOfFiles = pattern.substring(cutFromHere);
        for (File file : fileUtils.listFilesWithFilter(folder, "^(.+)" + endOfFiles + "$")) {
            resultPaths.add(file.getPath());
        }
    }
    return resultPaths;
}