List of usage examples for java.io File separatorChar
char separatorChar
To view the source code for java.io File separatorChar.
Click Source Link
From source file:coreferenceresolver.gui.MainGUI.java
/** * Creates new form MainGUI//ww w . j av a 2 s. co m */ public MainGUI() throws IOException { initComponents(); defaulPath = FileUtils.readFileToString(new File(".\\src\\coreferenceresolver\\gui\\defaultpath")); markupBtn.setEnabled(false); testBtn.setEnabled(false); trainingBtn.setEnabled(false); applyClassifierBtn.setEnabled(false); inputFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { markupBtn.setEnabled(false); testBtn.setEnabled(false); trainingBtn.setEnabled(false); applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { markupBtn.setEnabled(true); if (markupFilePathTF.getText() != null && !markupFilePathTF.getText().equals("")) { testBtn.setEnabled(true); trainingBtn.setEnabled(true); } if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("") && trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); markupFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { testBtn.setEnabled(false); trainingBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { testBtn.setEnabled(true); trainingBtn.setEnabled(true); } } }); testingFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (trainingFilePathTF.getText() != null && !trainingFilePathTF.getText().equals("") && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); trainingFilePathTF.getDocument().addDocumentListener(new DocumentListener() { // implement the methods public void changedUpdate(DocumentEvent e) { } public void removeUpdate(DocumentEvent e) { if (e.getDocument().getLength() == 0) { applyClassifierBtn.setEnabled(false); } } public void insertUpdate(DocumentEvent e) { if (testingFilePathTF.getText() != null && !testingFilePathTF.getText().equals("") && inputFilePathTF.getText() != null && !inputFilePathTF.getText().equals("")) { applyClassifierBtn.setEnabled(true); } } }); inputFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt"); markupFilePathTF.setText(defaulPath + File.separatorChar + "input_test.txt.markup"); trainingFilePathTF.setText(defaulPath + File.separatorChar + "train.arff"); testingFilePathTF.setText(defaulPath + File.separatorChar + "test.arff"); }
From source file:edu.stanford.muse.email.MboxEmailStore.java
private void collect_mbox_folders(List<FolderInfo> list, File f) throws MessagingException { if (!f.exists()) return;// w ww . j av a 2s . co m boolean noChildren = !f.isDirectory(); if (noChildren) { FolderInfo cachedFolderInfo = folderCache.lookup(f.getPath()); if (cachedFolderInfo != null) { if (cachedFolderInfo.messageCount > 0) list.add(cachedFolderInfo); log.info(Util.blurPath(f.getPath()) + " is in the folder cache, message count: " + cachedFolderInfo.messageCount); } else { try { // read the file String path = f.getPath(); if (path.endsWith(".msf")) return; // explicitly ignore msf files, sometimes it seems to read an actual number of messages even from msf files folderBeingScanned = f.getPath(); // folderBeingScannedShortName = Util.stripFrom(f.getPath(), rootPath + File.separatorChar); int idx = folderBeingScanned.lastIndexOf(File.separatorChar); if (idx >= 0 && (idx + 1) < folderBeingScanned.length()) folderBeingScannedShortName = folderBeingScanned.substring(idx + 1); else folderBeingScannedShortName = folderBeingScanned; Pair<Folder, Integer> pair = openFolder(null, f.getPath()); int count = pair.getSecond(); if (count == 1) { // many files are wrongly considered mbox with count 1. Ignore them if they also have a suffix that is known to cause noise. we're being cautious and ignoring these files only if they are noisy if (path.endsWith(".plist")) return; if (path.endsWith(".lock")) return; if (path.endsWith(".DS_Store")) // explicitly ignore .DS_store and ._.DS_Store files, annoying Mac OS binary files that get read as mbox by our parser return; log.info("Ignoring file " + path + " because it has only 1 message and its name matches a suffix that indicates it's likely not an mbox file."); } Folder f1 = pair.getFirst(); boolean validFolder = count > 0 && f1 != null; // we'll cache the folder info even if its not a valid folder. // this ensures we don't have to scan invalid folders again // if (validFolder) { if (f1 != null) f1.close(false); // put the info in the cache FolderInfo fi = new FolderInfo(null, folderBeingScanned, folderBeingScannedShortName, count); folderCache.put(f.getPath(), fi); if (validFolder) list.add(fi); folderBeingScanned = null; } } catch (Exception e) { log.error("Exception trying to read file " + f + ": " + e); } // store.close(); } } else { File filesInDir[] = f.listFiles(); if (filesInDir != null) // somehow this can be null when run on /tmp (maybe due to soft links etc). for (File child : filesInDir) collect_mbox_folders(list, child); } }
From source file:kihira.tails.client.gui.GuiExport.java
@Override protected void actionPerformed(GuiButton button) { //Export to file if (button.id == 0 || button.id == 1 || button.id == 2) { AbstractClientPlayer player = this.mc.thePlayer; File file;/*w w w .j a v a 2 s . c o m*/ this.exportMessage = ""; this.exportLoc = null; if (button.id == 0) file = new File(System.getProperty("user.home")); else if (button.id == 1) file = new File(System.getProperty("user.dir")); else { JFileChooser fileChooser = new JFileChooser(new File(System.getProperty("user.dir"))); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); if (fileChooser.showSaveDialog(Display.getParent()) == JFileChooser.APPROVE_OPTION) { file = fileChooser.getSelectedFile(); } else return; } if (file.exists() && file.canWrite()) { this.exportLoc = file.toURI(); file = new File(file, File.separatorChar + player.getCommandSenderName() + ".png"); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { setExportMessage( EnumChatFormatting.DARK_RED + String.format("Failed to create skin file! %s", e)); e.printStackTrace(); } } BufferedImage image = TextureHelper.writePartsDataToSkin(this.partsData, player); if (image != null) { try { ImageIO.write(image, "png", file); } catch (IOException e) { setExportMessage( EnumChatFormatting.DARK_RED + String.format("Failed to save skin file! %s", e)); e.printStackTrace(); } } else { setExportMessage( EnumChatFormatting.DARK_RED + String.format("Failed to export skin, image was null!")); file.delete(); } } if (Strings.isNullOrEmpty(this.exportMessage)) { savePartsData(); this.openFolderButton.visible = true; setExportMessage(EnumChatFormatting.GREEN + I18n.format("tails.export.success", file)); } } if (button.id == 3 && this.exportLoc != null) { try { Desktop.getDesktop().browse(this.exportLoc); } catch (IOException e) { setExportMessage( EnumChatFormatting.DARK_RED + String.format("Failed to open export location: %s", e)); e.printStackTrace(); } } //Upload if (button.id == 10) { final BufferedImage image = TextureHelper.writePartsDataToSkin(this.partsData, this.mc.thePlayer); Runnable runnable = new Runnable() { @Override public void run() { exportMessage = I18n.format("tails.uploading"); new ImgurUpload().uploadImage(image); } }; runnable.run(); } }
From source file:nc.noumea.mairie.appock.services.impl.CatalogueServiceImpl.java
@Override public File getFilePieceJointe(PhotoArticleCatalogue photoArticleCatalogue) { if (photoArticleCatalogue == null || photoArticleCatalogue.getId() == null) { throw new IllegalArgumentException("photoArticle null ou sans id : " + photoArticleCatalogue); }/* ww w . j a va 2 s.c o m*/ return new File(configService.getPieceJointeDir() + File.separatorChar + photoArticleCatalogue.getId()); }
From source file:be.makercafe.apps.makerbench.Main.java
/** * Setup workbench files/*from w w w . ja va 2 s . c o m*/ */ private void setupWorkspace() { File home = new File(this.pathMakerbenchHome); if (!home.exists()) { if (home.mkdir()) { // create makerbench home dir in users home File project = new File(this.pathMakerbenchHome + File.separatorChar + "project01"); if (project.mkdir()) { File jfxscadFile = new File( project.getAbsolutePath() + File.separatorChar + "example01.jfxscad"); String jfxscadSource = "CSG cube = new Cube(2).toCSG()\n" + "CSG sphere = new Sphere(1.25).toCSG()\n" + "\n" + "cube.difference(sphere)"; try { FileUtils.write(jfxscadFile, jfxscadSource); } catch (IOException e) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Unable to write example source code: " + jfxscadFile.getAbsolutePath(), e); } File readmeFile = new File(project.getAbsolutePath() + File.separatorChar + "readme.txt"); String readmeSource = "About makerbench"; try { FileUtils.write(readmeFile, readmeSource); } catch (IOException e) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Unable to write example source code: " + readmeFile.getAbsolutePath(), e); } } } } }
From source file:com.stimulus.archiva.domain.FileSystem.java
public String getBinPath() { return applicationPath + File.separatorChar + "WEB-INF" + File.separatorChar + "bin"; }
From source file:com.xeiam.datasets.common.business.DatasetsDAO.java
public static void init(String poolName, String dbName, String dataFilesDir, String dataFileURL, String propsFileURL, String scriptFileURL, String lobsFileURL, boolean requiresManualDownload) { // 1. create data dir // 1b. Clean up any stragglers FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".tmp")); FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".lck")); FileUtils.deleteQuietly(new File(dataFilesDir + "/" + dbName + ".log")); // 2. check if files are already available File dataFile = new File(dataFilesDir + "/" + dbName + ".data"); File propsFile = new File(dataFilesDir + "/" + dbName + ".properties"); File scriptFile = new File(dataFilesDir + "/" + dbName + ".script"); File lobsFile = new File(dataFilesDir + "/" + dbName + ".lobs"); // if the files don't yet exist, then download them if (!dataFile.exists() || !propsFile.exists() || !scriptFile.exists()) { logger.info("Saving DB files in: " + dataFilesDir); URL url;// www. ja v a 2 s .c o m try { // props logger.info("Downloading props file..."); url = new URL(GoogleDriveURLPart1 + propsFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, propsFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } try { // script logger.info("Downloading script file..."); url = new URL(GoogleDriveURLPart1 + scriptFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, scriptFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } // data if (!requiresManualDownload) { try { logger.info("Downloading data file... (this could take a while so be patient!)"); url = new URL(GoogleDriveURLPart1 + dataFileURL); org.apache.commons.io.FileUtils.copyURLToFile(url, dataFile, 5000, 10000); } catch (Exception e) { throw new RuntimeException( "Something went wrong while downloading the database files. Perhaps try again and if all else fails, download the files manually (https://drive.google.com/folderview?id=0ByP7_A9vXm17VXhuZzBrcnNubEE&usp=sharing) and place in the directory you specified.", e); } } else { throw new RuntimeException( "The data file is too big to download automatically! Please manually download it from: " + (GoogleDriveURLPart1 + dataFileURL) + " and place it in: " + dataFilesDir); } } else { logger.info("Database files already exist in local directory. Skipping download."); } if (lobsFileURL != null && !lobsFile.exists()) { throw new RuntimeException( "The data file is too big to download automatically! Please manually download it from: " + (GoogleDriveURLPart1 + lobsFileURL) + " and place it in: " + dataFilesDir); } // 3. setup HSQLDB Properties dbProps = new Properties(); dbProps.setProperty("driverclassname", "org.hsqldb.jdbcDriver"); dbProps.setProperty(poolName + ".url", "jdbc:hsqldb:file:" + dataFilesDir + File.separatorChar + dbName + ";shutdown=true;readonly=true"); dbProps.setProperty(poolName + ".user", "sa"); dbProps.setProperty(poolName + ".password", ""); dbProps.setProperty(poolName + ".maxconn", "10"); DBConnectionManager.INSTANCE.init(dbProps); }
From source file:eu.openanalytics.rpooli.RPooliContext.java
@Override public String getServerPolicyFilePath() throws RjInvalidConfigurationException { String path = servletContext.getRealPath("WEB-INF/lib"); if (isBlank(path) || !endsWithAny(path, "/", File.separator)) { path = path + File.separatorChar; }/*from w ww . j ava 2s . c om*/ return path + "security.policy"; }
From source file:net.sourceforge.ganttproject.gui.options.InterfaceOptionPageProvider.java
private static File getExtDir() { File fallback = new File(System.getProperty("java.home"), Joiner.on(File.separatorChar).join("lib", "ext")); String extDirsProperty = System.getProperty("java.ext.dirs"); if (Strings.isNullOrEmpty(extDirsProperty)) { return fallback; }/*from w ww .j a v a 2s.co m*/ for (String s : extDirsProperty.split(File.pathSeparator)) { File file = new File(s); if (!file.exists()) { continue; } if (!file.isDirectory()) { continue; } if (file.canWrite()) { return file; } fallback = file; } return fallback; }