/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Returns <code>null</code> if * the file does not exist. * @return the file */ public File getXMLFile() { if(file.exists() && file.isFile()) { return file; } else { try { file = FileUtil.findFile(file.getPath()); return file; } catch(FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath()); } } }
/** * Tries to open the file from its absolute or relative path. If the file * doesn't exist, tries to load the file with <code>getResource</code>. * Throws a <code>FileNotFoundException</code> if the file cannot be found. * @param fileName the file name * @return the file as reader * @throws FileNotFoundException if the cannot be found */ public static File findFile(String fileName) throws FileNotFoundException { File file = new File(fileName); if(isExistingFile(file)) return file; fileName = fileName.replace('\\', '/'); file = new File(fileName); if(isExistingFile(file)) return file; URL fileURL = FileUtil.class.getClassLoader().getResource(fileName); file = decodeFileURL(fileURL); if(null != file) return file; fileURL = FileUtil.class.getResource(fileName); file = decodeFileURL(fileURL); if(null != file) return file; throw new FileNotFoundException("Could not find file: " + fileName); }
List<String> lines = FileUtil.getLinesFromFile(fileToRead);
private static File decodeFileURL(URL fileURL) { if(fileURL != null) { File file = new File(fileURL.getFile()); if(isExistingFile(file)) return file; file = new File(URLDecoder.decode(fileURL.getFile())); if(isExistingFile(file)) return file; } return null; }
List lines = FileUtil.getLinesFromFile(fileToRead);
private static File decodeFileURL(URL fileURL) { if(fileURL != null) { File file = new File(fileURL.getFile()); if(isExistingFile(file)) return file; file = new File(URLDecoder.decode(fileURL.getFile())); if(isExistingFile(file)) return file; } return null; }
/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Throws a <code>RuntimeException</code> * if the file does not exist. * @return the file */ public File getFile() { if (file.exists() && file.isFile()) { return file; } else { try { file = FileUtil.findFile(file.getPath()); return file; } catch (FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath()); } } }
/** * Tries to open the file from its absolute or relative path. If the file * doesn't exist, tries to load the file with <code>getResource</code>. * Throws a <code>FileNotFoundException</code> if the file cannot be found. * @param fileName the file name * @return the file as reader * @throws FileNotFoundException if the cannot be found */ public static File findFile(String fileName) throws FileNotFoundException { File file = new File(fileName); if(isExistingFile(file)) return file; fileName = fileName.replace('\\', '/'); file = new File(fileName); if(isExistingFile(file)) return file; URL fileURL = FileUtil.class.getClassLoader().getResource(fileName); file = decodeFileURL(fileURL); if(null != file) return file; fileURL = FileUtil.class.getResource(fileName); file = decodeFileURL(fileURL); if(null != file) return file; throw new FileNotFoundException("Could not find file: " + fileName); }
List lines = FileUtil.getLinesFromFile(fileToRead);
/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Throws a <code>RuntimeException</code> * if the file does not exist. * @return the file */ public File getFile() { if (file.exists() && file.isFile()) return file; else { try { file = FileUtil.findFile(file.getPath()); } catch (FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath() + ". Current dir = " + System.getProperty("user.dir")); } } return file; }
/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Returns <code>null</code> if * the file does not exist. * @return the file */ public File getXMLFile() { if(file.exists() && file.isFile()) { return file; } else { try { file = FileUtil.findFile(file.getPath()); return file; } catch(FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath()); } } }
/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Returns <code>null</code> if * the file does not exist. * @return the file */ public File getXMLFile() { if(file.exists() && file.isFile()) { return file; } else { try { file = FileUtil.findFile(file.getPath()); return file; } catch(FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath()); } } }
/** * Get the <code>File</code> being used to read in the * <code>ResultSet</code>. Throws a <code>RuntimeException</code> * if the file does not exist. * @return the file */ public File getFile() { if (file.exists() && file.isFile()) { return file; } else { try { file = FileUtil.findFile(file.getPath()); return file; } catch (FileNotFoundException exc) { throw new RuntimeException("Could not find: " + file.getPath()); } } }