List of usage examples for java.io File toString
public String toString()
From source file:gr.auth.ee.lcs.evaluators.FileLogger.java
/** * A FileLogger constructor to set the directory in which the metrics are stored for all FileLoggers * and copy a backup of the src directory for debugging purposes * //from ww w . ja va2s .co m * * @author alexandros filotheou * * */ public FileLogger(final AbstractLearningClassifierSystem lcs) { file = null; actualEvaluator = null; final Calendar cal = Calendar.getInstance(); final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd 'at' kk.mm.ss"); String timestamp = sdf.format(cal.getTime()); // make directory hookedMetrics/{simpleDateFormat} File dir = new File("hookedMetrics/" + timestamp); System.out.println(dir.toString()); if (!dir.exists()) { dir.mkdirs(); } storeDirectory = "hookedMetrics/" + timestamp; dir = new File(storeDirectory + "/evals"); if (!dir.exists()) { dir.mkdirs(); } // set the name of the directory in which the metrics will be stored if (lcs.hookedMetricsFileDirectory == null) lcs.setHookedMetricsFileDirectory(storeDirectory); try { // keep a copy of thedefaultLcs.properties configuration File getConfigurationFile = new File(storeDirectory, "defaultLcs.properties"); if (!getConfigurationFile.exists()) { FileInputStream in = new FileInputStream("defaultLcs.properties"); FileOutputStream out = new FileOutputStream(storeDirectory + "/defaultLcs.properties"); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } } catch (Exception e) { e.printStackTrace(); } // copy the /src directory into storeDirectory String sourceDir = "src"; File srcDir = new File(sourceDir); String destinationDir = storeDirectory + "/src"; File destDir = new File(destinationDir); if (!destDir.exists()) destDir.mkdir(); try { FileUtils.copyDirectory(srcDir, destDir); } catch (Exception e) { e.printStackTrace(); } try { // record fitness mode, deletion mode and whether # participate in the correct sets in the file essentialSettings.txt final FileWriter fstream = new FileWriter(storeDirectory + "/essentialSettings.txt", true); final BufferedWriter buffer = new BufferedWriter(fstream); int fitness_mode = (int) SettingsLoader.getNumericSetting("FITNESS_MODE", 0); int deletion_mode = (int) SettingsLoader.getNumericSetting("DELETION_MODE", 0); boolean wildCardsParticipateInCorrectSets = String .valueOf(SettingsLoader.getStringSetting("wildCardsParticipateInCorrectSets", "true")) .equals("true"); boolean initializePopulation = String .valueOf(SettingsLoader.getStringSetting("initializePopulation", "true")).equals("true"); buffer.write("fitness mode: " + fitness_mode + System.getProperty("line.separator") + "deletion mode: " + deletion_mode + System.getProperty("line.separator") + "# in correct sets :" + wildCardsParticipateInCorrectSets + System.getProperty("line.separator") + (wildCardsParticipateInCorrectSets ? "balance correct sets: " + String.valueOf( SettingsLoader.getStringSetting("balanceCorrectSets", "true").equals("true")) + (String.valueOf( SettingsLoader.getStringSetting("balanceCorrectSets", "true").equals("true") ? ", with ratio: " + SettingsLoader .getNumericSetting("wildCardParticipationRatio", 0) : "")) : "" + System.getProperty("line.separator") + (initializePopulation ? "population initialized via clustering: " + initializePopulation : "") + System.getProperty("line.separator"))); buffer.flush(); buffer.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:io.fabric8.vertx.maven.plugin.utils.PackageHelper.java
/** * *///from w w w .j ava 2 s . co m protected void addDependencies() { Set<Optional<File>> all = new LinkedHashSet<>(compileAndRuntimeDeps); all.addAll(transitiveDeps); all.stream().filter(Optional::isPresent).forEach(dep -> { File f = dep.get(); if (log.isDebugEnabled()) { log.debug("Adding Dependency :" + f.toString()); } this.archive.as(ZipImporter.class).importFrom(f); }); }
From source file:edu.cornell.med.icb.goby.modes.ConcatenateCompactReadsMode.java
/** * Get the input filenames.//from ww w .ja va 2 s. c o m * * @return the input filenames */ public synchronized String[] getInputFilenames() { if (inputFiles == null) { return new String[0]; } final String[] array = new String[inputFiles.size()]; int i = 0; for (final File inputFile : inputFiles) { array[i++] = inputFile.toString(); } return array; }
From source file:com.bibisco.manager.ProjectManager.java
public static List<String> getDirectoryFileList(File pFileNode) { List<String> lFileList = new ArrayList<String>(); // add file only if (pFileNode.isFile()) { lFileList.add(pFileNode.toString()); }//from w ww . ja v a2s . co m if (pFileNode.isDirectory()) { String[] subNote = pFileNode.list(); for (String filename : subNote) { lFileList.addAll(getDirectoryFileList(new File(pFileNode, filename))); } } return lFileList; }
From source file:com.streamsets.datacollector.MiniSDCTestingUtility.java
/** * Sets up a directory for a test to use. * @return New directory path, if created. * @throws IOException/*from www .ja va 2 s . c o m*/ */ protected void setupDataTestDir() throws IOException { if (this.dataTestDir != null) { LOG.warn("Data test dir already setup in " + dataTestDir.getAbsolutePath()); return; } String randomStr = UUID.randomUUID().toString(); File testPath = new File(getBaseTestDir(), randomStr); this.dataTestDir = new File(testPath.toString()).getAbsoluteFile(); // Will be used by MiniSDC System.setProperty(TEST_DATA_DIR, this.dataTestDir.toString()); if (deleteOnExit()) { this.dataTestDir.deleteOnExit(); } dataTestDir.mkdirs(); LOG.debug("Test data dir setup at " + dataTestDir); }
From source file:cz.cas.lib.proarc.common.imports.TiffImporterTest.java
@Before public void setUp() throws Exception { junit = new UserProfile(); junit.setUserName("junit"); File root = temp.getRoot(); System.out.println("root: " + root.toString()); tiff1 = new File(root, "img1.tiff"); URL resource = TiffImporterTest.class.getResource("testscan-lzw.tiff"); FileUtils.copyURLToFile(resource, tiff1); assertTrue(tiff1.length() > 0);/*w w w . ja v a 2 s. c om*/ ocr1 = new File(root, "img1.ocr.txt"); FileUtils.writeStringToFile(ocr1, "test", "UTF-8"); alto1 = new File(root, "img1.ocr.xml"); FileUtils.writeStringToFile(alto1, "<alto xmlns=\"http://www.loc.gov/standards/alto/ns-v2#\">" + "<Layout><Page ID=\"Page1\" PHYSICAL_IMG_NR=\"1\"/></Layout>" + "</alto>", "UTF-8"); ac1 = new File(root, "img1.ac.jp2"); resource = TiffImporterTest.class.getResource("testscan.uc.jp2"); FileUtils.copyURLToFile(resource, ac1); assertTrue(ac1.length() > 0); uc1 = new File(root, "img1.uc.jp2"); FileUtils.copyURLToFile(resource, uc1); assertTrue(uc1.length() > 0); config = AppConfigurationFactory.getInstance().create(new HashMap<String, String>() { { put(AppConfiguration.PROPERTY_APP_HOME, temp.getRoot().getPath()); } }); jhoveContext = JhoveUtility.createContext(temp.newFolder("jhove")); DaoFactory daos = createMockDaoFactory(); ibm = new ImportBatchManager(config, daos); // MetaModelRepository.setInstance(new String[]{K4Plugin.ID}); MetaModelRepository.setInstance(new String[] { NdkPlugin.ID }); DigitalObjectManager.setDefault(new DigitalObjectManager(config, ibm, null, MetaModelRepository.getInstance(), EasyMock.createNiceMock(UserManager.class))); }
From source file:kihira.tails.common.FoxLibManager.java
private void deleteOldVersions() { File modsFolder = new File(Minecraft.getMinecraft().mcDataDir + File.separator + "mods"); File[] files = modsFolder//from w w w. j a va 2 s .c om .listFiles((FileFilter) new WildcardFileFilter("*FoxLib*.jar", IOCase.INSENSITIVE)); if (files != null) { for (File file : files) { if (file.exists()) { logger.info("Deleting file " + file.toString() + " on exit"); file.deleteOnExit(); } } } }
From source file:com.buaa.cfs.utils.FileUtil.java
/** * A wrapper for {@link File#listFiles()}. This java.io API returns null when a dir is not a directory or for any * I/O error. Instead of having null check everywhere File#listFiles() is used, we will add utility API to get * around this problem. For the majority of cases where we prefer an IOException to be thrown. * * @param dir directory for which listing should be performed * * @return list of files or empty list//w w w . j ava 2 s . co m * * @throws IOException for invalid directory or for a bad disk. */ public static File[] listFiles(File dir) throws IOException { File[] files = dir.listFiles(); if (files == null) { throw new IOException("Invalid directory or I/O error occurred for dir: " + dir.toString()); } return files; }
From source file:com.xpn.xwiki.pdf.impl.FileSystemURLFactory.java
/** * Store the requested attachment on the filesystem and return a {@code file://} URL where FOP can access that file. * * @param wiki the name of the owner document's wiki * @param spaces a serialized space reference which can contain one or several spaces (e.g. "space1.space2"). If * a space name contains a dot (".") it must be passed escaped as in "space1\.with\.dot.space2" * @param name the name of the owner document * @param filename the name of the attachment * @param revision an optional attachment version * @param context the current request context * @return a {@code file://} URL where the attachment has been stored * @throws Exception if the attachment can't be retrieved from the database and stored on the filesystem *//* ww w . j a v a 2 s.c o m*/ private URL getURL(String wiki, String spaces, String name, String filename, String revision, XWikiContext context) throws Exception { Map<String, File> usedFiles = getFileMapping(context); List<String> spaceNames = this.legacySpaceResolver.resolve(spaces); String key = getAttachmentKey(spaceNames, name, filename, revision); if (!usedFiles.containsKey(key)) { File file = getTemporaryFile(key, context); LOGGER.debug("Temporary PDF export file [{}]", file.toString()); XWikiDocument doc = context.getWiki().getDocument( new DocumentReference(StringUtils.defaultString(wiki, context.getWikiId()), spaceNames, name), context); XWikiAttachment attachment = doc.getAttachment(filename); if (StringUtils.isNotEmpty(revision)) { attachment = attachment.getAttachmentRevision(revision, context); } FileOutputStream fos = new FileOutputStream(file); IOUtils.copy(attachment.getContentInputStream(context), fos); fos.close(); usedFiles.put(key, file); } return usedFiles.get(key).toURI().toURL(); }
From source file:com.manning.androidhacks.hack040.util.ImageFetcher.java
/** * The main process method, which will be called by the ImageWorker in the * AsyncTask background thread./*from w w w.ja v a 2 s . co m*/ * * @param data * The data to load the bitmap, in this case, a regular http URL * @return The downloaded and resized bitmap */ private Bitmap processBitmap(String data) { if (BuildConfig.DEBUG) { Log.d(TAG, "processBitmap - " + data); } // Download a bitmap, write it to a file final File f = downloadBitmap(mActivity, data, mImageCache.getDiskCache()); if (f != null) { // Return a sampled down version return decodeSampledBitmapFromFile(f.toString(), mImageWidth, mImageHeight); } return null; }