List of usage examples for java.io File getPath
public String getPath()
From source file:Main.java
public static void compressFile(File file, File fileCompressed) throws IOException { byte[] buffer = new byte[SIZE_OF_BUFFER]; ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(fileCompressed)); FileInputStream fileInputStream = new FileInputStream(file); zipOutputStream.putNextEntry(new ZipEntry(file.getPath())); int size;/*from w ww . jav a 2s.c om*/ while ((size = fileInputStream.read(buffer)) > 0) zipOutputStream.write(buffer, 0, size); zipOutputStream.closeEntry(); fileInputStream.close(); zipOutputStream.close(); }
From source file:it.geosolutions.geostore.services.rest.auditing.AuditingConfiguration.java
private static File findConfigurationFile() { String configurationFilePath = System.getProperty(CONFIGURATION_PATH); if (configurationFilePath == null) { configurationFilePath = System.getenv(CONFIGURATION_PATH); }//from w ww . ja v a 2 s. c o m if (configurationFilePath == null) { LOGGER.warn("Could not found configuration path property."); return null; } File configurationFile = new File(configurationFilePath); if (!configurationFile.exists()) { throw new AuditingException("Configuration file '%s' does not exists.", configurationFile.getPath()); } return configurationFile; }
From source file:com.egt.core.db.util.SqlAgent.java
public static Process executeProcedure(String procedimiento, long funcion, Object[] args) { Bitacora.trace(SqlAgent.class, "executeProcedure", procedimiento, String.valueOf(funcion)); Utils.traceObjectArray(args);//from www. j a va 2 s.co m Long rastro = null; Process process = null; try { procedimiento = StringUtils.trimToEmpty(procedimiento); if (STP.esIdentificadorArchivoValido(procedimiento)) { if (TLC.getControlador().esFuncionAutorizada(funcion)) { rastro = TLC.getControlador().ponerProcesoPendiente(funcion); String command = EA.getString(EAC.SQLPRC_RUNNER_DIR) + EA.getString(EAC.SQLPRC_RUNNER_CMD); command += " " + commandParameters(procedimiento, funcion, rastro, args); String[] envp = null; File dir = new File(EA.getString(EAC.SQLPRC_RUNNER_DIR)); Bitacora.trace(command); Bitacora.trace(dir.getPath()); process = Runtime.getRuntime().exec(command, envp, dir); TLC.getBitacora().info(CBM2.PROCESS_EXECUTION_REQUEST, procedimiento); } else { throw new ExcepcionAplicacion( Bitacora.getTextoMensaje(CBM2.FUNCION_NO_AUTORIZADA, procedimiento)); } } else { throw new ExcepcionAplicacion( Bitacora.getTextoMensaje(CBM2.IDENTIFICADOR_ARCHIVO_INVALIDO, procedimiento)); } } catch (Exception ex) { EnumCondicionEjeFun condicion = EnumCondicionEjeFun.EJECUCION_CANCELADA; String mensaje = ThrowableUtils.getString(ex); Auditor.grabarRastroProceso(rastro, condicion, null, mensaje); TLC.getBitacora().error(mensaje); } return process; }
From source file:adalid.util.info.JavaInfo.java
public static void printManifestInfo(String extension, boolean details, File file) throws IOException { // String absolutePath = file.getAbsolutePath(); // String canonicalPath = file.getCanonicalPath(); String path = StringUtils.removeEndIgnoreCase(file.getPath(), FILE_SEP + MANIFEST_NAME); String name = StringUtils.substringAfterLast(path, FILE_SEP); InputStream stream = new FileInputStream(file); Manifest manifest = new Manifest(stream); if (!extensionNameMatches(manifest, extension)) { return;/*from w ww . ja va 2 s. c o m*/ } // out.println(absolutePath); // out.println(canonicalPath); printManifestInfo(path, name, details, manifest); }
From source file:forge.util.FileUtil.java
/** * Takes two paths and combines them into a valid path string * for the current OS.// w w w .j a va2 s .c o m * <p> * Similar to the Path.Combine() function in .Net. */ public static String pathCombine(String path1, String path2) { File file1 = new File(path1); File file2 = new File(file1, path2); return file2.getPath(); }
From source file:com.textocat.textokit.commons.consumer.XmiWriter.java
public static AnalysisEngineDescription createDescription(File outputDir, boolean writeToRelativePath) throws ResourceInitializationException { return AnalysisEngineFactory.createEngineDescription(XmiWriter.class, PARAM_OUTPUTDIR, outputDir.getPath(), PARAM_WRITE_TO_RELATIVE_PATH, writeToRelativePath); }
From source file:com.android.build.gradle.internal.transforms.ExtractJarsTransform.java
@NonNull private static File getFolder(@NonNull File outFolder, @NonNull File jarFile) { return new File(outFolder, jarFile.getName() + "-" + jarFile.getPath().hashCode()); }
From source file:de.tor.tribes.util.AttackToTextWriter.java
private static boolean writeBlocksToFiles(List<String> pBlocks, Tribe pTribe, File pPath) { int fileNo = 1; String baseFilename = pTribe.getName().replaceAll("\\W+", ""); for (String block : pBlocks) { String fileName = FilenameUtils.concat(pPath.getPath(), baseFilename + fileNo + ".txt"); FileWriter w = null;/*ww w.ja v a2s.c o m*/ try { w = new FileWriter(fileName); w.write(block); w.flush(); w.close(); } catch (IOException ioe) { logger.error("Failed to write attack to textfile", ioe); return false; } finally { if (w != null) { try { w.close(); } catch (IOException ignored) { } } } fileNo++; } return true; }
From source file:dk.clanie.io.IOUtil.java
/** * Adds all files in a directory and it's subdirectories to the supplied Collection. * /* www. j av a 2 s . co m*/ * @param dir * the directory to scan. * @param fileCollection * the Collection to update. */ public static void addFilesRecursively(File dir, Collection<File> fileCollection) { log.debug("Adding files from {}", dir.getPath()); File[] files = dir.listFiles(); for (File file : files) { if (file.isDirectory()) addFilesRecursively(file, fileCollection); else { fileCollection.add(file); } } }
From source file:averroes.JarFile.java
/** * Get the relative path for an absolute file path. * /*w w w .j a va 2 s . com*/ * @param dir * @param file * @return * @throws IOException */ public static String relativize(File base, File absolute) { Path pathAbsolute = java.nio.file.Paths.get(absolute.getPath()).normalize(); Path pathBase = java.nio.file.Paths.get(base.getPath()).normalize(); return pathBase.relativize(pathAbsolute).toString(); }