List of usage examples for java.io File toString
public String toString()
From source file:com.ubershy.streamsis.checkers.MultiTargetRegionChecker.java
@Override public void init() { elementInfo.setAsReadyAndHealthy();/*from w w w . j av a 2s .c o m*/ this.region = coords.generateRegion(); this.screen = (Screen) region.getScreen(); if (!this.region.isValid()) { elementInfo.setAsBroken("Something wrong with Region. Please enter valid Coordinates"); return; } if (similarity > 1 || similarity <= 0) { elementInfo.setAsBroken("Similarity parameter must be from 0 to 1.00"); return; } if (targetsPath.isEmpty()) { elementInfo.setAsBroken("Target images directory is not defined"); return; } File[] targetsList = Util.findFilesInDirectory(targetsPath, Util.singleStringAsArrayOfStrings(".png")); if (targetsList != null) { if (targetsList.length == 0) { elementInfo.setAsBroken( "No '.png' image files are found in the Target images directory" + targetsPath); return; } } else { elementInfo.setAsBroken("Something is wrong with the Target images directory" + targetsPath); return; } if (!elementInfo.isBroken()) { targets = new ArrayList<Pattern>(targetsList.length); for (File f : targetsList) { targets.add(new Pattern(f.toString()).similar(similarity)); } } }
From source file:com.evidon.areweprivateyet.Crawler.java
private String getDriverProfile() { // C:\Users\ADMINI~1\AppData\Local\Temp\2\ /**//from ww w .j a v a 2s . co m * The temporary profile Selenium/Firefox creates should be * located at java.io.tmpdir. Please check if its the same * on other OSes since I've used winblows. */ File sysTemp = new File(System.getProperty("java.io.tmpdir")); File pd = null; long prevTime = 0; for (File t : sysTemp.listFiles()) { if (!t.isDirectory()) { continue; } if (t.toString().contains("webdriver-profile")) { if (prevTime == 0) { prevTime = System.currentTimeMillis() - t.lastModified(); } if (prevTime >= System.currentTimeMillis() - t.lastModified()) { pd = t; prevTime = System.currentTimeMillis() - t.lastModified(); } } } return pd.toString(); }
From source file:me.StevenLawson.TotalFreedomMod.TFM_Util.java
public static void downloadFile(String url, File output, boolean verbose) throws java.lang.Exception { final URL website = new URL(url); ReadableByteChannel rbc = Channels.newChannel(website.openStream()); FileOutputStream fos = new FileOutputStream(output); fos.getChannel().transferFrom(rbc, 0, 1 << 24); fos.close();//from w w w . ja v a 2 s . c o m if (verbose) { TFM_Log.info("Downloaded " + url + " to " + output.toString() + "."); } }
From source file:com.pushtechnology.mvndar.AddDependenciesTask.java
@Override public void perform(final DARMojoContext context) throws IOException { // This only gets the direct dependencies. See // https://github.com/pushtechnology/mvndar/issues/1 @SuppressWarnings("unchecked") final Set<Artifact> dependencies = context.getProject().getDependencyArtifacts(); final Log log = context.getLog(); for (final Artifact a : dependencies) { if (a.isOptional()) { log.debug("Ignoring optional dependency: " + a); continue; }/* w w w . j a v a2 s .co m*/ if (!context.getAcceptedDependencyScopes().contains(a.getScope())) { log.debug("Ignoring dependency (scope): " + a); continue; } if ("com.pushtechnology".equals(a.getGroupId()) && "diffusion-api".equals(a.getArtifactId())) { continue; } if (context.getExtTypes().contains(a.getType())) { if (a.getFile() == null) { // Happens for relocated artifacts, e.g. // org.apache.commons:commons-io:jar:1.3.2 log.warn("Failed to locate dependency " + a + ", skipping"); continue; } final File f = a.getFile().getCanonicalFile(); final File target = FileUtils.getFile(context.getPrefixDirectoryName(), context.getExtDirectoryName(), f.getName()); context.getArchiver().addFile(f, target.toString()); log.debug("Dependency " + a + " has been copied to " + target); } else { log.debug("Ignoring dependency: " + a); } } }
From source file:net.sourceforge.floggy.eclipse.builder.MTJBuilder.java
/** * Make sure that the files or directories are available to the weaver, which doesn't understand eclipse project paths * @param path// w w w. j a v a 2s . c o m * @param project * @return */ private String getAccessablePathName(IPath path, IProject project) { String pathName = null; File pathFile = path.toFile(); if (pathFile != null && pathFile.exists()) { pathName = pathFile.toString(); } else { IFile pathIFile = project.getWorkspace().getRoot().getFile(path); if (pathIFile.getLocationURI() != null) { pathName = pathIFile.getLocationURI().getPath(); } } return pathName; }
From source file:co.cask.cdap.data.hbase.HBaseTestBase.java
@BeforeClass public void startHBase() throws Exception { conf = new Configuration(); // Set any necessary configurations (disable UIs to prevent port conflicts) conf.setInt("hbase.regionserver.info.port", -1); conf.setInt("hbase.master.info.port", -1); // Disable compression since it may not be available in environment where we run unit-test conf.set(HBaseTableUtil.CFG_HBASE_TABLE_COMPRESSION, "NONE"); // Start ZooKeeper zkCluster = new MiniZooKeeperCluster(conf); System.err.println("Starting ZK in 1 sec..."); Thread.sleep(1000);//w w w . java2 s . com int zkPort = zkCluster.startup(getRandomTempDir(), 1); System.err.println("\n\nStarted ZK on port " + zkPort + "\n\n\n"); // Add ZK info to conf conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(zkPort)); // Start DFS File dfsPath = getRandomTempDir(); System.setProperty("test.build.data", dfsPath.toString()); System.setProperty("test.cache.data", dfsPath.toString()); System.err.println("Instantiating dfs cluster in 1 sec..."); Thread.sleep(1000); dfsCluster = new MiniDFSCluster.Builder(conf).nameNodePort(0).numDataNodes(1).format(true) .manageDataDfsDirs(true).manageNameDfsDirs(true).build(); System.err.println("Waiting for dfs to start..."); dfsCluster.waitClusterUp(); System.err.println("DFS started..."); Thread.sleep(1000); // Add HDFS info to conf conf.set("fs.defaultFS", dfsCluster.getFileSystem().getUri().toString()); // Start HBase createHBaseRootDir(conf); conf.setInt("hbase.master.wait.on.regionservers.mintostart", 1); conf.setInt("hbase.master.wait.on.regionservers.maxtostart", 1); conf.set("hbase.master.logcleaner.plugins", ""); conf.setInt("zookeeper.session.timeout", 300000); // increasing session timeout for unit tests Configuration c = new Configuration(conf); System.err.println("Instantiating HBase cluster in 1 sec..."); Thread.sleep(1000); hbaseCluster = new MiniHBaseCluster(c, 1, 1); System.err.println("Just waiting around for a bit now"); Thread.sleep(1000); }
From source file:io.druid.indexing.common.tasklogs.HdfsTaskLogsTest.java
@Test public void testSimple() throws Exception { final File tmpDir = Files.createTempDir(); try {//from www . j a v a 2 s. c o m final File logDir = new File(tmpDir, "logs"); final File logFile = new File(tmpDir, "log"); Files.write("blah", logFile, Charsets.UTF_8); final TaskLogs taskLogs = new HdfsTaskLogs(new HdfsTaskLogsConfig(logDir.toString()), new Configuration()); taskLogs.pushTaskLog("foo", logFile); final Map<Long, String> expected = ImmutableMap.of(0L, "blah", 1L, "lah", -2L, "ah", -5L, "blah"); for (Map.Entry<Long, String> entry : expected.entrySet()) { final byte[] bytes = ByteStreams .toByteArray(taskLogs.streamTaskLog("foo", entry.getKey()).get().getInput()); final String string = new String(bytes); Assert.assertEquals(String.format("Read with offset %,d", entry.getKey()), string, entry.getValue()); } } finally { FileUtils.deleteDirectory(tmpDir); } }
From source file:com.norconex.committer.solr.SolrCommitterTest.java
@Before public void setup() throws Exception { File solrHome = tempFolder.newFolder("solr"); initCore("src/test/resources/solrconfig.xml", "src/test/resources/schema.xml", solrHome.toString()); server = new EmbeddedSolrServer(h.getCoreContainer(), h.getCore().getName()); committer = new SolrCommitter(new ISolrServerFactory() { private static final long serialVersionUID = 4648990433469043210L; @Override//www.j a v a 2 s. c o m public SolrServer createSolrServer(SolrCommitter solrCommitter) { return server; } }); queue = tempFolder.newFolder("queue"); committer.setQueueDir(queue.toString()); }
From source file:br.com.riselabs.cotonet.util.IOHandler.java
/** * Checks and removes either a file or a directory. No exceptions raised if * it fails.//from w ww . j a va 2 s .c om * * @param instance * @throws IOException */ public void checkAndRemove(File instance) throws IOException { if (getDirectory(instance) != null) { System.out.println("Removing old file: " + instance.toString()); FileUtils.deleteQuietly(instance); } }
From source file:com.netflix.spinnaker.halyard.deploy.services.v1.GenerateService.java
private Map<String, Profile> processProfiles(File spinnakerStaging, List<Profile> profiles) { for (Profile profile : profiles) { profile.writeStagedFile(spinnakerStaging.toString()); }//from w w w .j av a 2s . com Map<String, Profile> profileMap = new HashMap<>(); for (Profile profile : profiles) { profileMap.put(profile.getName(), profile); } return profileMap; }