/** * Tries to read an XML input stream and validate and marshal it. Returns a valid object of type T * if succesful. * * @param <T> The type that will be validated and marshalled * @param docClass The class that represents the type T * @param xmlFile The xml file to be parsed * @param schemaFile The schema file to validate the XML file * @return An object of type T filled with the content from the XML document (if everything went * right that is) * @throws JAXBException If the JAXB framework threw an error * @throws SAXException If the SAX framework threw an error * @throws FileNotFoundException If specified input files could not be read */ public static <T> T validateAndUnmarshal(Class<T> docClass, File xmlFile, File schemaFile) throws JAXBException, SAXException, FileNotFoundException { // try to get the file if (!xmlFile.isFile() || !schemaFile.isFile()) { throw new FileNotFoundException("Cannot find input file"); } InputStream inputStream = new FileInputStream(xmlFile); // get the schema to validate the inputStream later on SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema; try { schema = sf.newSchema(schemaFile.toURI().toURL()); } catch (MalformedURLException ex) { // should never happen throw new FileNotFoundException("Cannot find input file"); } // create the unmarshaller that will parse/validate/marshal the inputStream String packageName = docClass.getPackage().getName(); Unmarshaller unmarshaller = JAXBContext.newInstance(packageName).createUnmarshaller(); // set the schema that the unmarshaller will use unmarshaller.setSchema(schema); // unmarshal and return the type return (T) unmarshaller.unmarshal(inputStream); }
/** * Method to get the list of all files of a directory * * @param path * @return */ public boolean hasDirMovieFiles(String path) { File dir = new File(path); // Get all files of current directory File[] files = dir.listFiles(); if (files != null) { for (File f : files) { for (String str : validExtensions) { if (f.isFile() && f.getAbsolutePath().endsWith(str)) { return true; } } } } // Get all files of sub-directories String[] subdirs = getListSubdirectories(path); if (subdirs != null) { for (String subdir : subdirs) { File[] subFiles = new File(path + "/" + subdir).listFiles(); if (subFiles != null) { for (File f : subFiles) { for (String str : validExtensions) { if (f.isFile() && f.getAbsolutePath().endsWith(str)) { return true; } } } } } } return false; }
private static String getSeamVersionFromManifest(String seamHome) { File seamHomeFolder = new File(seamHome); if (seamHomeFolder == null || !seamHomeFolder.isDirectory()) { return null; } String[] seamFiles = seamHomeFolder.list( new FilenameFilter() { public boolean accept(File dir, String name) { if ("seam-gen".equals(name)) { // $NON-NLS-1$ return true; } if ("lib".equals(name)) { // $NON-NLS-1$ return true; } return false; } }); if (seamFiles == null || seamFiles.length != 2) { return null; } File jarFile = new File(seamHome, "lib/" + seamJarName); // $NON-NLS-1$ if (!jarFile.isFile()) { jarFile = new File(seamHome, seamJarName); if (!jarFile.isFile()) { return null; } } String[] attributes = new String[] {seamVersionAttributeName, RuntimeJarUtil.IMPLEMENTATION_VERSION}; return RuntimeJarUtil.getImplementationVersion(jarFile, attributes); }
/** * The full path name of the file to delete. * * @param path name * @return */ public int deleteTarget(String path) { File target = new File(path); if (target.exists() && target.isFile() && target.canWrite()) { target.delete(); return 0; } else if (target.exists() && target.isDirectory() && target.canRead()) { String[] file_list = target.list(); if (file_list != null && file_list.length == 0) { target.delete(); return 0; } else if (file_list != null && file_list.length > 0) { for (int i = 0; i < file_list.length; i++) { File temp_f = new File(target.getAbsolutePath() + "/" + file_list[i]); if (temp_f.isDirectory()) deleteTarget(temp_f.getAbsolutePath()); else if (temp_f.isFile()) temp_f.delete(); } } if (target.exists()) if (target.delete()) return 0; } return -1; }
public static void replayMetaProgramIn(String target, String repertory) throws Exception { File filep = new File(target); File file = new File(target + "/" + repertory); // this function doesn't work for a file and for inexistant file if (!file.exists() || !filep.exists()) { throw new Exception("no such directory"); } if (file.isFile() || filep.isFile()) throw new Exception("not a directory"); failures = 0; successes = 0; // make urls for classloader url = filep.toURI().toURL(); urls = new URL[] {url}; // create classloader cl = new URLClassLoader(urls); // finally run program replayMetaProgramWith(file, getPackage(repertory)); System.out.println("******************" + file.getName() + "******************"); System.out.println("total killed " + failures); System.out.println("total alive " + successes); }
protected boolean findLocalFile() { if ((localFile.exists() && localFile.isFile()) || (localZipFile.exists() && localZipFile.isFile())) { return true; } return false; }
public static void main(String[] args) { if (!isCommandFormatValid(args)) { printErrMessage(); System.exit(EXIT_ABNORMALLY); } if (isHelpNeeded(args)) { printHelpMessage(); System.exit(EXIT_ABNORMALLY); } if (!isFileValid(args)) { printErrMessage(); System.exit(EXIT_ABNORMALLY); } String fileName = args[1]; File fileOrDir = new File(fileName); if (fileName.endsWith("xml") && fileOrDir.isFile() && fileOrDir.canRead()) { logger.info("Process single file: " + fileName); processSingleFile(fileName); } else if (fileOrDir.isDirectory()) { File[] files = fileOrDir.listFiles(); if (files != null && files.length > 0) { for (final File f : files) { if (f.isFile() && f.canRead() && f.getName().endsWith("xml")) { logger.info("Processing file: " + f.getPath()); System.out.println("Processing file: " + f.getPath()); processSingleFile(f.getPath()); } } } } }
public File getFile(String fileName) { try { File file; if (fileName.contains(testDirectory.getCanonicalPath())) { String relativeFileName = fileName.substring(testDirectory.getCanonicalPath().length() + 1, fileName.length()); file = new File(testDirectory, relativeFileName); if (file.exists()) { if (file.isFile()) return file; } } else for (int i = 0; i < moduleDirectories.length; i++) { if (fileName.contains(moduleDirectories[i].getCanonicalPath())) { String relativeFileName = fileName.substring( moduleDirectories[i].getCanonicalPath().length() + 1, fileName.length()); file = new File(moduleDirectories[i], relativeFileName); } else file = new File(moduleDirectories[i], fileName); if (file.exists()) { if (file.isFile()) return file; } } file = new File(fixtureDirectory, fileName); if (file.exists()) return file; } catch (IOException e) { e.printStackTrace(); return null; } return null; }
public static Container setup() throws IOException { Properties properties = new Properties(); File revProps = new File("revenj.properties"); if (revProps.exists() && revProps.isFile()) { properties.load(new FileReader(revProps)); } else { String location = System.getProperty("revenj.properties"); if (location != null) { revProps = new File(location); if (revProps.exists() && revProps.isFile()) { properties.load(new FileReader(revProps)); } else { throw new IOException( "Unable to find revenj.properties in alternative location. Searching in: " + revProps.getAbsolutePath()); } } else { throw new IOException( "Unable to find revenj.properties. Searching in: " + revProps.getAbsolutePath()); } } String plugins = properties.getProperty("revenj.pluginsPath"); File pluginsPath = null; if (plugins != null) { File pp = new File(plugins); pluginsPath = pp.isDirectory() ? pp : null; } return setup( dataSource(properties), properties, Optional.ofNullable(pluginsPath), Optional.ofNullable(Thread.currentThread().getContextClassLoader())); }
private void deployAll() throws GlassFishException { // deploy explicit wars first. int deploymentCount = 0; Deployer deployer = gf.getDeployer(); if (deployments != null) { for (File war : deployments) { if (war.exists() && war.isFile() && war.canRead()) { deployer.deploy(war, "--availabilityenabled=true"); deploymentCount++; } else { logger.log(Level.WARNING, "{0} is not a valid deployment", war.getAbsolutePath()); } } } // deploy from deployment director if (deploymentRoot != null) { for (File war : deploymentRoot.listFiles()) { String warPath = war.getAbsolutePath(); if (war.isFile() && war.canRead() && (warPath.endsWith(".war") || warPath.endsWith(".ear") || warPath.endsWith(".jar") || warPath.endsWith(".rar"))) { deployer.deploy(war, "--availabilityenabled=true"); deploymentCount++; } } } logger.log(Level.INFO, "Deployed {0} wars", deploymentCount); }
static boolean canAttemptRead(File repositoryDir) { File requiredP2ArtifactsFile = new File(repositoryDir, RepositoryLayoutHelper.FILE_NAME_P2_ARTIFACTS); File requiredLocalArtifactsFile = new File(repositoryDir, RepositoryLayoutHelper.FILE_NAME_LOCAL_ARTIFACTS); return requiredP2ArtifactsFile.isFile() && requiredLocalArtifactsFile.isFile(); }
@Override public int compare(File filea, File fileb) { return ((filea.isFile() ? "a" : "b") + filea.getName().toLowerCase(Locale.getDefault())) .compareTo( (fileb.isFile() ? "a" : "b") + fileb.getName().toLowerCase(Locale.getDefault())); }
@Override public void execute(String[] args) throws IOException { File source = controller.getFileFromName(args[1]); File target = controller.getFileFromName(args[2]); if (!source.exists()) { throw new IOException("cp: \"" + args[1] + "\": No such file or directory"); } if (source.equals(target)) { throw new IOException("cp: \"" + args[1] + "\" and \"" + args[2] + "\" are the same file"); } if (source.isFile()) { if (!target.exists()) { controller.copyFile(source, target); } else { if (target.isDirectory()) { copyRecursive(source, target); } else { throw new IOException("cp: can not copy file to existing file"); } } } else if (source.isDirectory()) { if (target.isFile() || !target.exists()) { throw new IOException("cp: omitting directory \"" + args[1] + "\""); } else { copyRecursive(source, target); } } }
@Override protected void run() throws Exception { if (!really && !db.getAllRefs().isEmpty()) { final StringBuilder m = new StringBuilder(); m.append("fatal: "); m.append("This program will destroy the repository:"); m.append("\n"); m.append("fatal:\n"); m.append("fatal: "); m.append(db.getDirectory().getAbsolutePath()); m.append("\n"); m.append("fatal:\n"); m.append("fatal: "); m.append("To continue, add "); m.append(REALLY); m.append(" to the command line"); m.append("\n"); m.append("fatal:"); System.err.println(m); throw die("Need approval to destroy current repository"); } if (!refList.isFile()) throw die("no such file: " + refList.getPath()); if (!graph.isFile()) throw die("no such file: " + graph.getPath()); recreateCommitGraph(); detachHead(); deleteAllRefs(); recreateRefs(); }
TransportAmazonS3(final Repository local, final URIish uri) throws NotSupportedException { super(local, uri); Properties props = null; File propsFile = new File(local.getDirectory(), uri.getUser()); if (!propsFile.isFile()) propsFile = new File(FS.userHome(), uri.getUser()); if (propsFile.isFile()) { try { props = AmazonS3.properties(propsFile); } catch (IOException e) { throw new NotSupportedException("cannot read " + propsFile, e); } } else { props = new Properties(); props.setProperty("accesskey", uri.getUser()); props.setProperty("secretkey", uri.getPass()); } s3 = new AmazonS3(props); bucket = uri.getHost(); String p = uri.getPath(); if (p.startsWith("/")) p = p.substring(1); if (p.endsWith("/")) p = p.substring(0, p.length() - 1); keyPrefix = p; }
/* initial statistics used for calculating word metadata such as word vectors to train on */ protected void calcWordFrequencies() { numFiles = countFiles(); CountDownLatch latch = new CountDownLatch(numFiles); ActorRef fileActor = system.actorOf( new RoundRobinPool(Runtime.getRuntime().availableProcessors()) .props(Props.create(VocabCreatorActor.class, this, latch))); for (File f : rootDir.listFiles()) { File[] subFiles = f.listFiles(); if (f.isFile()) fileActor.tell(f, fileActor); else if (subFiles != null) for (File doc : subFiles) { if (!doc.isFile()) continue; fileActor.tell(doc, fileActor); } } try { latch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } log.info("Done calculating word frequencies"); }
protected Pair<BigInteger, Boolean> getSizeOf(Object obj) { if (obj == null) return null; if (!(obj instanceof File)) return null; File f = (File) obj; if (f.isFile()) return new BasicPair<BigInteger, Boolean>(BigInteger.valueOf(f.length()), false); if (f.isDirectory()) { boolean hasContinuousChild = ttable.getCachedChildren(obj) == null; BigInteger size = BigInteger.ZERO; for (TreeWalk tw : ttable.walkCachedChildren(obj, TreeWalkType.ByLevel)) { Object n = tw.currentNode(); if (n instanceof ChildrenReader) { hasContinuousChild = true; } else if (n instanceof File) { File nf = (File) n; if (nf.isFile()) { size = size.add(BigInteger.valueOf(nf.length())); } else if (nf.isDirectory()) { if (ttable.getCachedChildren(nf) == null) { hasContinuousChild = true; } } } } return new BasicPair<BigInteger, Boolean>(size, hasContinuousChild); } return null; }
public static boolean copyFile(File source, File dest, boolean mkdirs, boolean overwrite) { if (mkdirs) dest.getParentFile().mkdirs(); if (!source.isFile()) return false; if (dest.isFile() && !isSameFile(dest)) dest.delete(); if (dest.isFile() && !overwrite) return false; if (!dest.exists()) try { dest.createNewFile(); } catch (IOException e1) { JMXTestPlugin.log(e1); } InputStream is = null; OutputStream os = null; try { is = new BufferedInputStream(new FileInputStream(source), 16 * 1024); os = new BufferedOutputStream(new FileOutputStream(dest), 16 * 1024); copyStream(is, os); return true; } catch (IOException e) { JMXTestPlugin.log(e); return false; } finally { try { if (is != null) is.close(); } catch (IOException e) { JMXTestPlugin.log(e); } try { if (os != null) os.close(); } catch (IOException e) { JMXTestPlugin.log(e); } } }
private Resource extractDeploymentPropertiesResource(final String path) { /* First check if we were passed a file path */ File tryFile = new File(path); if (tryFile.isFile()) { logger.debug("Path {} successfully resolved to a file", path); return new FileSystemResource(tryFile); } /* If not a file path, see if it's a File relative to the current directory */ tryFile = new File(System.getProperty("user.dir"), path); if (tryFile.isFile()) { logger.debug( "Path {} successfully resolved to relative file {}", path, tryFile.getAbsolutePath()); return new FileSystemResource(tryFile); } /* See if the resource exists in the ClassPath */ final ClassPathResource classPathResource = new ClassPathResource(path); if (classPathResource.exists()) { logger.debug("Path {} successfully found in ClassPath", path); return classPathResource; } /* No luck then, Ted? */ return null; }
public static boolean updateFile(File source, File dest, boolean mkdirs) { if (!source.isFile()) return false; if (dest.isFile() && (dest.lastModified() < source.lastModified())) { dest.delete(); } return copyFile(source, dest, mkdirs); }
private static String getDefaultFilePath() { System.out.println("Trying to look for the default properties file :: " + PROPERTIES_FILE_NAME); // look for the file in current directory File f = new File(PROPERTIES_FILE_NAME); if (f.isFile()) { System.out.println("Found one in - " + f.getAbsolutePath()); return f.getAbsolutePath(); } // look for the file in default path f = new File(DEFAULT_PATH + File.separatorChar + PROPERTIES_FILE_NAME); if (f.isFile()) { System.out.println("Found one in - " + f.getAbsolutePath()); return f.getAbsolutePath(); } // Check whether its present in the bin folder f = new File("bin" + File.separatorChar + PROPERTIES_FILE_NAME); if (f.isFile()) { System.out.println("Found one in - " + f.getAbsolutePath()); return f.getAbsolutePath(); } System.out.println("Not found - try to load it using the classpath"); return PROPERTIES_FILE_NAME; }
/** * @param bigg * @param input * @param output * @param parameters * @throws IOException * @throws XMLStreamException */ public void batchProcess(BiGGDB bigg, File input, File output, Parameters parameters) throws IOException, XMLStreamException { // We test if non-existing path denotes a file or directory by checking if // it contains at least one period in its name. If so, we assume it is a // file. if (!output.exists() && (output.getName().lastIndexOf('.') < 0) && !(input.isFile() && input.getName().equals(output.getName()))) { logger.info(MessageFormat.format("Creating directory {0}.", output.getAbsolutePath())); output.mkdir(); } if (input.isFile()) { boolean jsonFile = SBFileFilter.hasFileType(input, SBFileFilter.FileType.JSON_FILES); boolean matFile = SBFileFilter.hasFileType(input, SBFileFilter.FileType.MAT_FILES); if (SBFileFilter.isSBMLFile(input) || matFile || jsonFile) { if (output.isDirectory()) { String fName = input.getName(); if (matFile || jsonFile) { fName = FileTools.removeFileExtension(fName) + ".xml"; } output = new File(Utils.ensureSlash(output.getAbsolutePath()) + fName); } polish(bigg, input, output, parameters); } } else { if (!output.isDirectory()) { throw new IOException( MessageFormat.format("Cannot write to file {0}.", output.getAbsolutePath())); } for (File file : input.listFiles()) { File target = new File(Utils.ensureSlash(output.getAbsolutePath()) + file.getName()); batchProcess(bigg, file, target, parameters); } } }
/** * Loads the configuration file for the application, if it exists. This is either the * user-specified properties file, or the spark-defaults.conf file under the Spark configuration * directory. */ Properties loadPropertiesFile() throws IOException { Properties props = new Properties(); File propsFile; if (propertiesFile != null) { propsFile = new File(propertiesFile); CommandBuilderUtils.checkArgument( propsFile.isFile(), "Invalid properties file '%s'.", propertiesFile); } else { propsFile = new File(getConfDir(), CommandBuilderUtils.DEFAULT_PROPERTIES_FILE); } if (propsFile.isFile()) { FileInputStream fd = null; try { fd = new FileInputStream(propsFile); props.load(new InputStreamReader(fd, "UTF-8")); for (Map.Entry<Object, Object> e : props.entrySet()) { e.setValue(e.getValue().toString().trim()); } } finally { if (fd != null) { try { fd.close(); } catch (IOException e) { // Ignore. } } } } return props; }
/** * Load item properties. * * @param path the path * @return the item properties */ protected ItemProperties loadItemProperties(String path) { File target = new File(getStorageBaseDir(), path); File mdTarget = new File(getMetadataBaseDir(), path); ItemProperties ip = getProxiedItemPropertiesFactory().expandItemProperties(path, target, true); if (target.isFile() && isMetadataAware()) { try { if (mdTarget.exists() && mdTarget.isFile()) { Properties metadata = new Properties(); FileInputStream fis = new FileInputStream(mdTarget); try { metadata.load(fis); } finally { fis.close(); } ip.getAllMetadata().putAll(metadata); } else { logger.debug( "No metadata exists for [{}] on path [{}] " + "-- recreating the default ones. " + "Reindex operation may be needed to recreate/reindex them completely.", ip.getName(), ip.getDirectoryPath()); ip = getProxiedItemPropertiesFactory().expandItemProperties(path, target, true); storeItemProperties(ip); } } catch (IOException ex) { logger.error("Got IOException during metadata retrieval.", ex); } } return ip; }
@NotNull public static String getProjectRepresentationName( @NotNull String targetProjectPath, @Nullable String rootProjectPath) { if (rootProjectPath == null) { File rootProjectDir = new File(targetProjectPath); if (rootProjectDir.isFile()) { rootProjectDir = rootProjectDir.getParentFile(); } return rootProjectDir.getName(); } File rootProjectDir = new File(rootProjectPath); if (rootProjectDir.isFile()) { rootProjectDir = rootProjectDir.getParentFile(); } File targetProjectDir = new File(targetProjectPath); if (targetProjectDir.isFile()) { targetProjectDir = targetProjectDir.getParentFile(); } StringBuilder buffer = new StringBuilder(); for (File f = targetProjectDir; f != null && !FileUtil.filesEqual(f, rootProjectDir); f = f.getParentFile()) { buffer.insert(0, f.getName()).insert(0, ":"); } buffer.insert(0, rootProjectDir.getName()); return buffer.toString(); }
public static void generate(File propertiesFile) throws FileNotFoundException, IOException, IllegalArgumentException { if (!propertiesFile.exists() || !propertiesFile.isFile()) { throw new IllegalArgumentException("Please specify a legal target."); } String name = propertiesFile.getName().replace(".filter.properties", ".g"); File input = new File(propertiesFile.getParentFile(), name); if (!input.exists() || !input.isFile()) { throw new IllegalArgumentException( "Could not find the grammar corresponding to the filter properties file: " + propertiesFile); } Properties properties = new Properties(); properties.load(new FileInputStream(propertiesFile)); String pack = properties.getProperty("package"); if (pack == null) { throw new IllegalArgumentException("Incomplete specification in filter properties."); } generate(input, pack); }
@Override protected List<String> getApplicationStartCommands(File root) { ArrayList<String> lst = new ArrayList<String>(); File restartBinary = new File(root, "JDownloader.exe"); if (!restartBinary.exists() || !restartBinary.isFile()) restartBinary = new File(root, "JDownloader2.exe"); if (!restartBinary.exists() || !restartBinary.isFile()) restartBinary = new File(root, "JDownloader 2.exe"); if (restartBinary.exists() && restartBinary.isFile()) { getLogger().info("Found binary: " + restartBinary + " for restart"); try { String binaryHash = Hash.getMD5(restartBinary); if ("a08b3424355c839138f326c06a964b9e".equals(binaryHash)) { getLogger() .info( "Workaround: found locking binary " + binaryHash + "! Will use JavaBinary as workaround!"); restartBinary = null; } } catch (final Throwable e) { getLogger().log(e); } } else { restartBinary = null; } if (restartBinary != null) { lst.add(restartBinary.getAbsolutePath()); } else { getLogger().info("No binary found! Will use JavaBinary!"); lst.addAll(getJVMApplicationStartCommands(root)); } return lst; }
/** * Given an output root and an initial relative path, return the output file according to the * HANDLE_EXISTING strategy * * <p>In the most basic use case, given a root directory "input", a file's relative path * "dir1/dir2/fileA.docx", and an output directory "output", the output file would be * "output/dir1/dir2/fileA.docx." * * <p>If HANDLE_EXISTING is set to OVERWRITE, this will not check to see if the output already * exists, and the returned file could overwrite an existing file!!! * * <p>If HANDLE_EXISTING is set to RENAME, this will try to increment a counter at the end of the * file name (fileA(2).docx) until there is a file name that doesn't exist. * * <p>This will return null if handleExisting == HANDLE_EXISTING.SKIP and the candidate file * already exists. * * <p>This will throw an IOException if HANDLE_EXISTING is set to RENAME, and a candidate cannot * output file cannot be found after trying to increment the file count (e.g. fileA(2).docx) 10000 * times and then after trying 20,000 UUIDs. * * @param outputRoot directory root for output * @param initialRelativePath initial relative path (including file name, which may be renamed) * @param handleExisting what to do if the output file exists * @param suffix suffix to add to files, can be null * @return output file or null if no output file should be created * @throws java.io.IOException */ public static File getOutputFile( File outputRoot, String initialRelativePath, HANDLE_EXISTING handleExisting, String suffix) throws IOException { String localSuffix = (suffix == null) ? "" : suffix; File cand = new File(outputRoot, initialRelativePath + "." + localSuffix); if (cand.isFile()) { if (handleExisting.equals(HANDLE_EXISTING.OVERWRITE)) { return cand; } else if (handleExisting.equals(HANDLE_EXISTING.SKIP)) { return null; } } // if we're here, the output file exists, and // we must find a new name for it. // groups for "testfile(1).txt": // group(1) is "testfile" // group(2) is 1 // group(3) is "txt" // Note: group(2) can be null int cnt = 0; String fNameBase = null; String fNameExt = ""; // this doesn't include the addition of the localSuffix File candOnly = new File(outputRoot, initialRelativePath); Matcher m = FILE_NAME_PATTERN.matcher(candOnly.getName()); if (m.find()) { fNameBase = m.group(1); if (m.group(2) != null) { try { cnt = Integer.parseInt(m.group(2)); } catch (NumberFormatException e) { // swallow } } if (m.group(3) != null) { fNameExt = m.group(3); } } File outputParent = cand.getParentFile(); while (fNameBase != null && cand.isFile() && ++cnt < 10000) { String candFileName = fNameBase + "(" + cnt + ")." + fNameExt + "" + localSuffix; cand = new File(outputParent, candFileName); } // reset count to 0 and try 20000 times cnt = 0; while (cand.isFile() && cnt++ < 20000) { UUID uid = UUID.randomUUID(); cand = new File(outputParent, uid.toString() + fNameExt + "" + localSuffix); } if (cand.isFile()) { throw new IOException( "Couldn't find candidate output file after trying " + "very, very hard"); } return cand; }
private void compareBinaryFolder(String path, boolean res) throws BrutException, IOException { Boolean exists = true; String tmp = ""; if (res) { tmp = File.separatorChar + "res" + File.separatorChar; } String location = tmp + path; FileDirectory fileDirectory = new FileDirectory(sTestOrigDir + location); Set<String> files = fileDirectory.getFiles(true); for (String filename : files) { File control = new File((sTestOrigDir + location), filename); File test = new File((sTestNewDir + location), filename); if (!test.isFile() || !control.isFile()) { exists = false; } } assertTrue(exists); }
protected void prepareFileChooser(String url, JFileChooser fc) { if (url == null || url.trim().length() == 0) return; URL sourceUrl = null; try { sourceUrl = new URL(url); } catch (MalformedURLException e) { File f = new File(url); if (f.isFile()) { f = f.getParentFile(); } if (f != null) { fc.setCurrentDirectory(f); } return; } if (sourceUrl.getProtocol().startsWith("file")) { File f = new File(sourceUrl.getPath()); if (f.isFile()) { f = f.getParentFile(); } if (f != null) { fc.setCurrentDirectory(f); } } }