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:edu.stanford.muse.webapp.GroupsConfig.java
/** returns status of success */ public static boolean delete(String dir, String session) throws IOException, ClassNotFoundException { if (dir == null) return false; String filename = dir + File.separatorChar + session + GROUPING_SUFFIX; File f = new File(filename); if (!f.exists()) return false; // empty result return f.delete(); }
From source file:com.msopentech.odatajclient.testservice.utils.Commons.java
public static String getEntityBasePath(final String entitySetName, final String entityKey) { return entitySetName + File.separatorChar + getEntityKey(entityKey) + File.separatorChar; }
From source file:com.fatwire.dta.sscrawler.reporting.reporters.PageCollectingReporter.java
public void addToReport(final ResultPage page) { if (page.getResponseCode() != 200) { return; // bail out }/*w w w . j ava 2 s.c o m*/ final long id = idGen.incrementAndGet(); FileWriter writer = null; try { final String p = (page.getPageName() != null ? page.getPageName() : "") + "-" + id + ".txt"; final File pFile = new File(dir, p); pwriter.println(page.getUri() + "\t" + path + File.separator + p.replace('/', File.separatorChar)); pwriter.flush(); pFile.getAbsoluteFile().getParentFile().mkdirs(); writer = new FileWriter(pFile); writer.write(page.getUri().toString()); writer.write(PageCollectingReporter.CRLF); writer.write(PageCollectingReporter.CRLF); final Header[] headers = page.getResponseHeaders(); for (final Header header : headers) { writer.write(header.toExternalForm()); } writer.write(PageCollectingReporter.CRLF); writer.write(page.getBody()); } catch (final IOException e) { log.error(e, e); } finally { if (writer != null) { try { writer.close(); } catch (final IOException ignored) { // ignored } } } }
From source file:com.flipkart.poseidon.serviceclients.generator.Generator.java
private static boolean validateInput(String[] args) { if (args.length < 2) { return false; }//from ww w.j av a2 s .c om int lastIndex = args[0].lastIndexOf(File.separatorChar); if (lastIndex <= 0) { logger.error("Invalid module path"); return false; } modulePath = args[0]; moduleName = modulePath.substring(lastIndex + 1); if (!moduleName.matches("^[a-zA-Z_]*$")) { logger.error("Invalid module name. Should contain only alphabets and underscore"); return false; } moduleParentPath = modulePath.substring(0, lastIndex); determineVersion(args[1]); String majorVersion = "v" + version.getMajor(); packageName = PACKAGE_NAME + moduleName + "." + majorVersion; if (args.length > 2) { pojoOrdering = args[2].split(","); } return true; }
From source file:com.appspresso.api.fs.FileSystemUtils.java
/** * path prefix ?.// w w w .j a v a 2s . com * * @param path ? path * @param prefix path ? prefix * @return path prefix {@literal true}, {@literal false} . */ public static boolean hasPrefix(String path, String prefix) { if (!path.startsWith(prefix)) return false; if (path.equals(prefix)) return true; return File.separatorChar == path.charAt(prefix.length()); }
From source file:AIR.ResourceBundler.Console.ResourcesBuilder.java
private void processParentResource(FileSet fileSet) throws Exception { String outputFile = Path.combine(_parentFolder, fileSet.getOutput()); outputFile = outputFile.replace('/', File.separatorChar); File outputFolder = new File(outputFile).getParentFile(); // make sure output folder exists if (!outputFolder.exists()) { FileUtils.forceMkdir(outputFolder); }//w w w . j a v a 2 s. co m File output = new File(outputFile); output.createNewFile(); FileWriter sw = new FileWriter(output); sw.write("/*\n"); sw.write(String.format("Copyright (c) %s, American Institutes for Research. All rights reserved.\n", DateTime.getNow().getYear())); sw.write(String.format("GENERATED: %s\n", DateTime.getNow().toString())); // TODO Shajib: In .net code Environment.MachineName used int machineHash = HttpContext.getCurrentContext().getServer().hashCode(); String machineID = Integer.toString(machineHash); sw.write(String.format("MACHINE: %s\n", machineID)); sw.write("*/\n"); sw.write("\n"); Iterator<FileSetInput> it = _resources.getFileInputs(fileSet.getName()); FileSetInput file = null; for (; it.hasNext();) { file = it.next(); writeFileInput(sw, file); } }
From source file:de.petermoesenthin.alarming.util.FileUtil.java
/** * Copies a file to the Alarming directory in the external storage * * @param context Application context//from ww w .ja va 2s .c om * @param uri Uri of file to copy */ public static void saveFileToExtAppStorage(final Context context, final Uri uri, final OnCopyFinishedListener op) { final File applicationDirectory = getApplicationDirectory(); if (!applicationDirectory.exists()) { applicationDirectory.mkdirs(); } File noMedia = new File(applicationDirectory.getPath() + File.separatorChar + ".nomedia"); if (!noMedia.exists()) { try { noMedia.createNewFile(); Log.e(DEBUG_TAG, "Created .nomedia file in: " + noMedia.getAbsolutePath()); } catch (IOException e) { Log.e(DEBUG_TAG, "Unable to create .nomedia file", e); } } String fileName = getFilenameFromUriNoSpace(uri); final File destinationFile = new File(applicationDirectory.getPath() + File.separatorChar + fileName); Log.d(DEBUG_TAG, "Source file name: " + fileName); Log.d(DEBUG_TAG, "Source file uri: " + uri.toString()); Log.d(DEBUG_TAG, "Destination file: " + destinationFile.getPath()); Thread copyThread = new Thread(new Runnable() { @Override public void run() { BufferedInputStream bis = null; BufferedOutputStream bos = null; if (isExternalStorageWritable()) { try { InputStream uriStream = context.getContentResolver().openInputStream(uri); bis = new BufferedInputStream(uriStream); bos = new BufferedOutputStream(new FileOutputStream(destinationFile.getPath(), false)); byte[] buf = new byte[1024]; while (bis.read(buf) != -1) { bos.write(buf); } } catch (IOException e) { Log.e(DEBUG_TAG, "Unable to copy file from URI", e); } finally { try { if (bis != null) bis.close(); if (bos != null) bos.close(); } catch (IOException e) { Log.e(DEBUG_TAG, "Unable to close buffers", e); } } } if (op != null) { op.onOperationFinished(); } } }); copyThread.start(); }
From source file:net.sasasin.sreader.batch.SingleAccountFeedReader.java
public void run() { logger.info(this.getClass().getSimpleName() + " is started."); File path = new File(System.getProperty("user.home") + File.separatorChar + "sreader.txt"); if (!path.exists() || !path.isFile() || !path.canRead()) { System.out.println("FAIL;" + path.getPath() + " can not proc."); return;//from w w w. j a v a 2 s . co m } List<String> lines = null; try { lines = IOUtils.readLines(new FileReader(path)); } catch (IOException e) { e.printStackTrace(); return; } // import path to feed_url table. importSubscribe(lines); logger.info(this.getClass().getSimpleName() + " is ended."); }
From source file:com.microsoft.office.core.AbstractPropertyTest.java
@Test public void readPropertyValue() throws IOException { final InputStream input = getClass().getResourceAsStream( getVersion().name().toLowerCase() + File.separatorChar + "Customer_-10_CustomerId_value.txt"); final ODataValue value = getClient().getPrimitiveValueBuilder().setType(EdmSimpleType.String) .setText(IOUtils.toString(input)).build(); assertNotNull(value);//from ww w . j a va 2 s. co m assertEquals("-10", value.toString()); }
From source file:com.jaxio.celerio.output.EclipseCodeFormatter.java
@Autowired public EclipseCodeFormatter(Config config, EclipseProfilesLoader loader) { EclipseFormatter eclipseFormatter = config.getCelerio().getConfiguration().getConventions() .getEclipseFormatter();/* w w w.j a v a 2s . c o m*/ formatterChoice = eclipseFormatter.getFormatterChoice(); switch (formatterChoice) { case USE_FORMATTER_FILE: String filePath = config.getBaseDir() + File.separatorChar + eclipseFormatter.getFormatterFile(); try { setFormatterSettings(loader.loadSettingsFromEclipseFile(new File(filePath))); } catch (IOException ioe) { log.error( "Could not create the Eclipse Code Formatter. Please check the path to your formatter filer.", ioe); formatterChoice = FormatterEnum.NONE; } break; case USE_ECLIPSE_DEFAULT: setFormatterSettings(null); break; case NONE: break; } }