List of usage examples for java.io File getAbsoluteFile
public File getAbsoluteFile()
From source file:aes.pica.touresbalon.tb_serviciosbolivariano.ServiciosBolivarianos.java
@Override public List<ViajeVO> consultarViajes(String fechaViaje, String ciudadOrigen, String ciudadDestino, String horaSalida) {// w ww. j a va 2 s . c o m List<ViajeVO> listaViajes = new ArrayList<>(); String nombreArchivo = Constantes.NAME_VIAJES + fechaViaje + Constantes.CSV_FILE; try { File archivoConsulta = FileUtils.getFile(rutaConsulta, nombreArchivo); if (archivoConsulta != null && archivoConsulta.exists()) { List<String> lineasArchivo = FileUtils.readLines(archivoConsulta); System.out.println("Archivo encontrado: " + archivoConsulta.getAbsoluteFile()); ViajeVO viajeAux; for (String s : lineasArchivo) { viajeAux = new ViajeVO(s); if (viajeAux.getCiudadOrigen().equalsIgnoreCase(ciudadOrigen) && viajeAux.getCiudadDestino().equalsIgnoreCase(ciudadDestino) && viajeAux.getHoraSalida().equalsIgnoreCase(horaSalida)) { listaViajes.add(viajeAux); } } } else { System.out.println("No existe archivo: " + nombreArchivo + " en el directorio: " + rutaConsulta); } } catch (IOException ex) { System.err.println(ex.toString()); } return listaViajes; }
From source file:com.heliosphere.athena.base.file.internal.resource.AbstractResource.java
/** * Loads the file considering its pathname is relative. * <hr>//from w w w .j a va 2 s. c om * @param pathname Resource path name. * @return {@code True} if the resource can be loaded, {@code false} otherwise. */ @SuppressWarnings({ "nls", "unused" }) private final boolean loadRelativeSeparator(String pathname) { URL url = null; // Try to remove the leading file separator, if one exist. if (pathname.startsWith(File.separator)) { try { // Maybe the file pathname is relative. url = Thread.currentThread().getContextClassLoader() .getResource(pathname.replaceFirst(File.separator, "")); this.file = new File(url.toURI()); if (!file.exists()) { try { file.createNewFile(); } catch (IOException ioe) { return false; } } } catch (Exception e) { // Try to get the parent directory of the file ... maybe the file does not exist! file = new File(pathname); String name = FilenameUtils.getName(pathname); File directory = file.getParentFile(); try { url = Thread.currentThread().getContextClassLoader() .getResource(file.getParent().replaceFirst(File.separator, "")); try { directory = new File(url.toURI()); if (directory.getAbsoluteFile().exists() && directory.getAbsoluteFile().isDirectory()) { // OK, found the parent directory, then create the file as it does not exist. file = new File(directory.getAbsolutePath() + File.separator + name); try { file.createNewFile(); } catch (IOException e1) { return false; } } } catch (URISyntaxException urie) { return false; } } catch (Exception e2) { return false; } } } if (file == null) { return false; } return this.file.exists(); }
From source file:de.uzk.hki.da.grid.IrodsCommandLineConnector.java
/** * executes given rule against the iRODS Server * @author Jens Peters/*from w ww . ja v a2s . c om*/ * @param rule * @return */ public String executeIrule(File rule) { String commandAsArray[] = new String[] { "irule", "-F", rule.getAbsoluteFile().toString() }; return executeIcommand(commandAsArray); }
From source file:net.sf.firemox.tools.MToolKit.java
/** * Return the deck file chosen//from w w w. j ava 2 s. c o m * * @param parent * is parent of this dialog * @param type * open or save option * @return the file chosen, or the previous one if canceled. */ public static String getDeckFile(JFrame parent, int type) { String deckFile = Configuration.getString("decks.deck(0)", ""); try { File file = MToolKit.getFile(deckFile); if (file == null) { file = showDialogFile("choose your deck file", 'o', null, txtFilter, parent, type); } else { file = showDialogFile("choose your deck file", 'o', file.getAbsoluteFile(), txtFilter, parent, type); } if (file != null) { deckFile = getShortDeckFile(file.getCanonicalPath()); } else return null; return deckFile; } catch (IOException e) { JOptionPane.showMessageDialog(parent, "Error occurred reading the specified file", "File problem", JOptionPane.ERROR_MESSAGE); return Configuration.getString("decks.deck(0)", ""); } catch (Exception e) { // cancel of user; return null; } }
From source file:hudson.Util.java
/** * Checks if the given file represents a symlink. *///w w w.java 2s.co m public static boolean isSymlink(File file) throws IOException { String name = file.getName(); if (name.equals(".") || name.equals("..")) { return false; } File fileInCanonicalParent; File parentDir = file.getParentFile(); if (parentDir == null) { fileInCanonicalParent = file; } else { fileInCanonicalParent = new File(parentDir.getCanonicalPath(), name); } return !fileInCanonicalParent.getCanonicalFile().equals(fileInCanonicalParent.getAbsoluteFile()); }
From source file:net.mindengine.galen.api.Galen.java
public static void dumpPage(Browser browser, String pageName, PageSpec pageSpec, File reportFolder, Integer maxWidth, Integer maxHeight) throws IOException { if (!reportFolder.exists()) { if (!reportFolder.mkdirs()) { throw new RuntimeException("Cannot create dir: " + reportFolder.getAbsolutePath()); }/*from w w w .j a v a 2s .c o m*/ } Set<String> objectNames = pageSpec.getObjects().keySet(); PageValidation pageValidation = new PageValidation(browser, browser.getPage(), pageSpec, null, null); PageDump pageDump = new PageDump(); pageDump.setTitle(browser.getPage().getTitle()); for (String objectName : objectNames) { PageElement pageElement = pageValidation.findPageElement(objectName); if (pageElement.isVisible() && pageElement.getArea() != null) { PageDump.Element element = new PageDump.Element(objectName, pageElement.getArea().toIntArray(), pageElement.getText()); if (pageElement.isPresent() && pageElement.isVisible() && isWithinArea(pageElement, maxWidth, maxHeight)) { element.setHasImage(true); } pageDump.addElement(element); } } pageDump.setPageName(pageName); pageDump.exportAsJson(new File(reportFolder.getAbsoluteFile() + File.separator + "page.json")); pageDump.exportAsHtml(pageName, new File(reportFolder.getAbsoluteFile() + File.separator + "page.html")); pageDump.exportAllScreenshots(browser, reportFolder); copyResource("/html-report/jquery-1.11.2.min.js", new File(reportFolder.getAbsolutePath() + File.separator + "jquery-1.11.2.min.js")); copyResource("/pagedump/galen-pagedump.js", new File(reportFolder.getAbsolutePath() + File.separator + "galen-pagedump.js")); copyResource("/pagedump/galen-pagedump.css", new File(reportFolder.getAbsolutePath() + File.separator + "galen-pagedump.css")); }
From source file:com.redhat.rcm.version.mgr.capture.MissingInfoCapture.java
public void captureMissing(final VersionManagerSession session) { final Map<VersionlessProjectKey, Set<Dependency>> missingDeps = session.getMissingDependencies(); final Map<VersionlessProjectKey, Set<Plugin>> missingPlugins = session.getUnmanagedPluginRefs(); final Set<Project> missingParents = session.getProjectsWithMissingParent(); final Map<String, String> missingVersionProps = session.getMissingVersionProperties(); final boolean procDeps = notEmpty(missingDeps); final boolean procPlugs = notEmpty(missingPlugins); final boolean procParents = notEmpty(missingParents); final boolean procProps = notEmpty(missingVersionProps); if (procProps || procDeps || procPlugs) { final SimpleDateFormat format = new SimpleDateFormat(VERSION_DATE_PATTERN); final Model model = new Model(); model.setModelVersion("4.0.0"); model.setGroupId(Cli.class.getPackage().getName()); model.setArtifactId("vman-missing-capture"); model.setVersion(format.format(new Date())); model.setPackaging("pom"); boolean write = false; write = processCurrentProjects(session, model) || write; if (procProps) { write = processProperties(missingVersionProps, model) || write; }/* w w w . ja v a 2s.c om*/ if (procDeps) { write = processDependencies(missingDeps, model) || write; } if (procPlugs) { write = processPlugins(missingPlugins, model) || write; } if (procParents) { write = processParents(missingParents, model) || write; } if (write) { final File capturePom = session.getCapturePom(); Writer writer = null; try { final File dir = capturePom.getAbsoluteFile().getParentFile(); if (dir != null && !dir.exists()) { dir.mkdirs(); } writer = WriterFactory.newXmlWriter(capturePom); new MavenXpp3Writer().write(writer, model); } catch (final IOException e) { session.addError(new VManException("Failed to write capture POM: %s. Reason: %s", e, capturePom, e.getMessage())); } finally { closeQuietly(writer); } } } }
From source file:com.digitalgeneralists.assurance.UnitTestUtils.java
public String readTestFileContents(File file) throws FileNotFoundException, IOException { String contents = null;// w ww. j a v a2 s . c om FileReader fr = new FileReader(file.getAbsoluteFile()); BufferedReader br = new BufferedReader(fr); String currentLine = null; while ((currentLine = br.readLine()) != null) { contents += currentLine; } br.close(); fr.close(); return contents; }
From source file:esiptestbed.mudrod.ontology.pre.AggregateTriples.java
/** * Method of executing triple aggregation *///from ww w . j a va2 s. c o m @Override public Object execute() { File file = new File(this.props.getProperty("oceanTriples")); if (file.exists()) { file.delete(); } try { file.createNewFile(); } catch (IOException e2) { e2.printStackTrace(); } FileWriter fw; try { fw = new FileWriter(file.getAbsoluteFile()); bw = new BufferedWriter(fw); } catch (IOException e) { e.printStackTrace(); } File[] files = new File(this.props.getProperty("ontologyInputDir")).listFiles(); for (File file_in : files) { String ext = FilenameUtils.getExtension(file_in.getAbsolutePath()); if ("owl".equals(ext)) { try { loadxml(file_in.getAbsolutePath()); getAllClass(); } catch (JDOMException e1) { e1.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } } } try { bw.close(); } catch (IOException e) { e.printStackTrace(); } return null; }