List of usage examples for java.io File toString
public String toString()
From source file:fll.subjective.SubjectiveFrame.java
/** * Set the initial directory preference. This supports opening new file * dialogs to a (hopefully) better default in the user's next session. * //from ww w. java 2 s .com * @param dir the File for the directory in which file dialogs should open */ private static void setInitialDirectory(final File dir) { // Store only directories final File directory; if (dir.isDirectory()) { directory = dir; } else { directory = dir.getParentFile(); } final Preferences preferences = Preferences.userNodeForPackage(SubjectiveFrame.class); final String previousPath = preferences.get(INITIAL_DIRECTORY_PREFERENCE_KEY, null); if (!directory.toString().equals(previousPath)) { preferences.put(INITIAL_DIRECTORY_PREFERENCE_KEY, directory.toString()); } }
From source file:com.github.hexocraft.worldrestorer.WorldRestorerApi.java
public static boolean deleteWorldSave(JavaPlugin plugin, String worldName) { // Folder to delete File worldFolder = new File(plugin.getDataFolder() + "/" + worldSaves + "/" + worldName); // Check/* w ww .ja v a2s .c o m*/ if (!worldFolder.exists()) { WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix, "Failed to delete the saved world '" + worldName + "'. This world doesn't exist"); return false; } // Delete the folder if (worldFolder.exists() && !deleteWorldFolder(worldFolder)) { WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix, "Failed to delete the folder '" + worldFolder.toString() + "'."); return false; } // Check if (worldFolder.exists()) { WarningPrefixedMessage.toConsole(WorldRestorer.instance, prefix, "Failed to delete the saved world '" + worldName + "'."); return false; } SimplePrefixedMessage.toConsole(WorldRestorer.instance, prefix, "The saved world " + worldName + " was deleted."); return true; }
From source file:net.nicoulaj.compilecommand.CompileCommandProcessorTest.java
private Object[][] getDataProvider(File sourceDir, File resourceDir) throws IOException { final List<Object[]> data = new ArrayList<Object[]>(); final File[] sources = sourceDir.listFiles(); if (sources == null) throw new IllegalArgumentException("No source in " + sourceDir); sort(sources);//from w w w . ja v a 2 s .co m for (File source : sources) if ("java".equals(getExtension(source.toString()))) if (!"package-info".equals(getBaseName(source.toString()))) data.add(new Object[] { source, new File(resourceDir, getBaseName(source.toString())) }); return data.toArray(new Object[data.size()][]); }
From source file:boa.compiler.BoaCompiler.java
private static void compileGeneratedSrc(final CommandLine cl, final String jarName, final File outputRoot, final File outputFile) throws RuntimeException, IOException, FileNotFoundException { // compile the generated .java file final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) throw new RuntimeException( "Could not get javac - are you running the Boa compiler with a JDK or a JRE?"); LOG.info("compiling: " + outputFile); LOG.info("classpath: " + System.getProperty("java.class.path")); if (compiler.run(null, null, null, "-source", "5", "-target", "5", "-cp", System.getProperty("java.class.path"), outputFile.toString()) != 0) throw new RuntimeException("compile failed"); final List<File> libJars = new ArrayList<File>(); if (cl.hasOption('j')) { libJars.add(new File(cl.getOptionValue('j'))); } else {/*w w w.java2 s .c om*/ // find the location of the jar this class is in final String path = ClasspathUrlFinder.findClassBase(BoaCompiler.class).getPath(); // find the location of the compiler distribution final File root = new File(path.substring(path.indexOf(':') + 1, path.indexOf('!'))).getParentFile(); libJars.add(new File(root, "boa-runtime.jar")); } if (cl.hasOption('l')) for (final String s : Arrays.asList(cl.getOptionValues('l'))) libJars.add(new File(s)); generateJar(jarName, outputRoot, libJars); if (DefaultProperties.localDataPath == null) { delete(outputRoot); } }
From source file:gool.executor.java.JavaCompiler.java
@Override public File compileToExecutable(List<File> files, File mainFile, List<File> classPath, List<String> args) throws FileNotFoundException { List<String> params = new ArrayList<String>(); params.add("javac"); params.add("-d"); params.add(getOutputDir().getAbsolutePath()); params.add("-d"); params.add(getOutputDir().getAbsolutePath()); addClasspathArgs(classPath, params); if (mainFile == null) { mainFile = files.get(0);/* w w w. j a v a 2s . co m*/ } for (File file : files) { params.add(file.toString()); } if (args != null) { params.addAll(args); } Command.exec(getOutputDir(), params); return (new File(getOutputDir(), mainFile.getName().replace(".java", ".class"))); }
From source file:com.grarak.kerneladiutor.database.tools.profiles.ExportProfile.java
public boolean export(String name) { if (!name.endsWith(".json")) name += ".json"; File exportFiles = new File(Utils.getInternalDataStorage() + "/profiles"); File file = new File(exportFiles.toString() + "/" + name); if (file.exists()) return false; exportFiles.mkdirs();/*from www . jav a 2s . c om*/ Utils.writeFile(file.toString(), mMain.toString(), false, false); return true; }
From source file:com.grarak.kerneladiutor.database.tools.customcontrols.ExportControl.java
public boolean export(String name) { if (!name.endsWith(".json")) name += ".json"; File exportFiles = new File(Utils.getInternalDataStorage() + "/controls"); File file = new File(exportFiles.toString() + "/" + name); if (file.exists()) return false; exportFiles.mkdirs();/*from w ww.j a va2 s. c o m*/ Utils.writeFile(file.toString(), mMain.toString(), false, false); return true; }
From source file:ijfx.core.IjfxTest.java
public void displayFile(File file) throws IOException { System.out.println(file.toString()); if (file.getName().endsWith(".gz")) { FileInputStream fis = new FileInputStream(file); GZIPInputStream gis = new GZIPInputStream(fis); Reader decoder = new InputStreamReader(gis, "utf-8"); BufferedReader buffered = new BufferedReader(decoder); String line = buffered.readLine(); while (line != null) { System.out.println(line); line = buffered.readLine();// www . ja v a 2s. co m } } else { System.out.println(FileUtils.readFileToString(file)); } }
From source file:ch.vorburger.mariadb4j.StartSimulatedForAllPlatformsTest.java
void checkManagedProcessExists(ManagedProcess proc) { File installProcFile = proc.getExecutableFile(); assertTrue("Does not exist: " + installProcFile.toString(), installProcFile.exists()); assertTrue("Is not a File: " + installProcFile.toString(), installProcFile.isFile()); }
From source file:functionaltests.scripts.clean.TestJobCleaningScriptVariables.java
@Test public void testJobCleaningScriptVariables() throws Throwable { HashMap<String, String> variables = new HashMap<>(); File ko = new File(tmpDir.getRoot(), "ko"); variables.put("path", ko.toString()); variables.put("test", "initialValue"); JobId jobId = schedulerHelper.submitJob(new File(jobDescriptor.toURI()).getAbsolutePath(), variables); schedulerHelper.waitForEventJobFinished(jobId); while (schedulerHelper.getResourceManager().getState() .getFreeNodesNumber() != SchedulerStartForFunctionalTest.RM_NODE_NUMBER) ;//from ww w . jav a2 s. c o m if (ko.exists()) { String content; content = FileUtils.readFileToString(ko); Assert.fail(content); } }