List of usage examples for java.io File getAbsoluteFile
public File getAbsoluteFile()
From source file:com.joker.gankor.utils.ASimpleCache.java
public static ASimpleCache get(File cacheDir, long max_zise, int max_count) { ASimpleCache manager = mInstanceMap.get(cacheDir.getAbsoluteFile() + myPid()); if (manager == null) { manager = new ASimpleCache(cacheDir, max_zise, max_count); mInstanceMap.put(cacheDir.getAbsolutePath() + myPid(), manager); }/*from ww w. jav a 2s.com*/ return manager; }
From source file:com.crte.sipstackhome.ui.preferences.PreferencesWrapper.java
/** * /* w w w . j a v a2 s . c om*/ * @param ctxt * @param subFolder * @param preferCache * @return */ private static File getSubFolder(Context ctxt, String subFolder, boolean preferCache) { File root = getStorageFolder(ctxt, preferCache); if (root != null) { File dir = new File(root.getAbsoluteFile() + File.separator + subFolder); dir.mkdirs(); return dir; } return null; }
From source file:com.github.riccardove.easyjasub.EasyJaSubInputFromCommand.java
private static File abs(File file) { return file != null ? file.getAbsoluteFile() : null; }
From source file:com.chinaztt.fda.cache.ACache.java
/** * ??,?Map????map//from w w w. j a v a 2s . co m * @param cacheDir * @param max_zise * @param max_count * @return */ public static ACache get(File cacheDir, long max_zise, int max_count) { 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.smartmarmot.common.Configurator.java
public static Properties getPropsFromFile(String _filename) { try {/* w w w . j av a2 s .c om*/ verifyConfig(); Properties propsq = new Properties(); FileInputStream fisq; if (_filename != "" && _filename != null) { File queryFile = new File(_filename); fisq = new FileInputStream(new java.io.File(queryFile.getAbsoluteFile().getCanonicalPath())); queryFile = null; SmartLogger.logThis(Level.DEBUG, "Loaded the properties from " + _filename); propsq.load(fisq); fisq.close(); return propsq; } } catch (Exception e) { // TODO Auto-generated catch block SmartLogger.logThis(Level.ERROR, "Error on Configurator reading properties file getPropsFromFile(" + _filename + ") " + e.getMessage()); return null; } return null; }
From source file:com.wavemaker.commons.util.IOUtils.java
/** * Create intermediate directories so that the File represented by newFile can be created. * * @param newDir The directory that will be created; this method will ensure that the intermediate directories * exist, and that this File is within the topLevel file. * @param topLevel This file should represent the top-level directory that files will not be created outside of. *//*from w w w. j ava2 s. c om*/ public static void makeDirectories(File newDir, File topLevel) throws FileAccessException { if (newDir.exists()) { return; } if (!topLevel.exists()) { throw new FileAccessException(MessageResource.UTIL_FILEUTILS_PATHDNE, topLevel); } else if (!topLevel.isDirectory()) { throw new FileAccessException(MessageResource.UTIL_FILEUTILS_PATHNOTDIR, topLevel); } File absNewFile = newDir.getAbsoluteFile(); IOUtils.makeDirectoriesRecurse(absNewFile, topLevel); }
From source file:com.smartmarmot.orabbix.Configurator.java
protected static Properties getPropsFromFile(String _filename) { try {/*from w w w . ja v a2s . c o m*/ verifyConfig(); Properties propsq = new Properties(); FileInputStream fisq; if (_filename != "" && _filename != null) { File queryFile = new File(_filename); fisq = new FileInputStream(new java.io.File(queryFile.getAbsoluteFile().getCanonicalPath())); queryFile = null; SmartLogger.logThis(Level.DEBUG, "Loaded the properties from " + _filename); propsq.load(fisq); fisq.close(); return propsq; } } catch (Exception e) { // TODO Auto-generated catch block SmartLogger.logThis(Level.ERROR, "Error on Configurator reading properties file getPropsFromFile(" + _filename + ") " + e.getMessage()); return null; } return null; }
From source file:com.mosso.client.cloudfiles.sample.FilesCopy.java
/** * * @param folder/*from w w w . ja va 2s.c o m*/ * @return null if the input is not a folder otherwise a zip file containing all the files in the folder with nested folders skipped. * @throws IOException */ public static File zipFolder(File folder) throws IOException { byte[] buf = new byte[1024]; int len; // Create the ZIP file String filenameWithZipExt = folder.getName() + ZIPEXTENSION; File zippedFile = new File(FilenameUtils.concat(SYSTEM_TMP.getAbsolutePath(), filenameWithZipExt)); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zippedFile)); if (folder.isDirectory()) { File[] files = folder.listFiles(); for (File f : files) { if (!f.isDirectory()) { FileInputStream in = new FileInputStream(f); // Add ZIP entry to output stream. out.putNextEntry(new ZipEntry(f.getName())); // Transfer bytes from the file to the ZIP file while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } // Complete the entry out.closeEntry(); in.close(); } else logger.warn("Skipping nested folder: " + f.getAbsoluteFile()); } out.flush(); out.close(); } else { logger.warn("The folder name supplied is not a folder!"); System.err.println("The folder name supplied is not a folder!"); return null; } return zippedFile; }
From source file:com.smartmarmot.common.Configurator.java
public static boolean propVerify(String _prop) { // TODO Auto-generated method stub if (_prop != null) { if (!_prop.isEmpty() && !_prop.equals("")) { Properties props = new Properties(); FileInputStream fisq; File queryFile = new File(_prop); try { fisq = new FileInputStream(new java.io.File(queryFile.getAbsoluteFile().getCanonicalPath())); props.load(fisq);//from www . ja v a 2s . c o m fisq.close(); return true; } catch (Exception ex) { SmartLogger.logThis(Level.DEBUG, "Error on Configurator while checking file " + _prop + " " + ex); return false; } } } return false; }
From source file:exifIndexer.MetadataReader.java
public static void walk(String path, boolean is_recursive) { File root = new File(path); File[] list = root.listFiles(); String filePath;//from w ww. j a v a2 s . c o m String fileName; String fileExt; String valueName; String tagName; String catName; Metadata metadata; long fileSize; long fileLastModified; java.util.Date utilDate; java.sql.Date sqlDate; String sql = "{ ? = call INSERTIMAGE(?,?,?,?,?) }"; String sqlMetaData = "{ call INSERTMETADATA (?,?,?,?) }"; CallableStatement statement; CallableStatement statementMeta; long result; if (list == null) { return; } for (File f : list) { if (f.isDirectory() && is_recursive) { walk(f.getAbsolutePath(), true); } else { filePath = FilenameUtils.getFullPath(f.getAbsolutePath()); fileName = FilenameUtils.getBaseName(f.getName()); fileExt = FilenameUtils.getExtension(f.getName()); utilDate = new java.util.Date(f.lastModified()); sqlDate = new java.sql.Date(utilDate.getTime()); fileSize = f.length(); try { metadata = ImageMetadataReader.readMetadata(f.getAbsoluteFile()); try { DBHandler db = new DBHandler(); db.openConnection(); Connection con = db.getCon(); // llamada al metodo insertar imagen SQL con (filePath,fileName,fileExtension,fileSize, fileLastModified) statement = con.prepareCall(sql); statement.setString(2, filePath); statement.setString(3, fileName); statement.setString(4, fileExt); statement.setLong(5, fileSize); statement.setDate(6, sqlDate); statement.registerOutParameter(1, java.sql.Types.NUMERIC); statement.execute(); result = statement.getLong(1); // llamada al metodo insertar metadatos SQL con (idImg,valueName, tagName, catName) for (Directory directory : metadata.getDirectories()) { for (Tag tag : directory.getTags()) { valueName = tag.getDescription(); tagName = tag.getTagName(); catName = directory.getName(); if (isNull(valueName) || isNull(tagName) || isNull(catName) || valueName.equals("") || tagName.equals("") || catName.equals("") || valueName.length() > 250 || tagName.length() > 250 || catName.length() > 500) { System.out.println("Exif row omitted."); System.out.println("Omitting: [" + catName + "] " + tagName + " " + valueName); } else { statementMeta = con.prepareCall(sqlMetaData); statementMeta.setLong(1, result); statementMeta.setString(2, valueName); statementMeta.setString(3, tagName); statementMeta.setString(4, catName); statementMeta.executeUpdate(); } } } db.closeConnection(); } catch (SQLException ex) { System.err.println("Error with SQL command. \n" + ex); } } catch (ImageProcessingException e) { System.out.println("ImageProcessingException " + e); } catch (IOException e) { System.out.println("IOException " + e); } } } }