List of usage examples for java.io File getName
public String getName()
From source file:com.cjwagner.InfoSecPriv.ExtensionServer.java
private static void initializeLogStore() { System.out.println("Date: " + new Date().getTime()); System.out.println("Initializing Log Store..."); int fileLoadCount = 0; storeSize = 0;//w w w .j a v a 2 s. c o m logStore = new ConcurrentHashMap<String, LoggerMessage>(); File dir = new File(logDir); dir.mkdir(); File[] files = dir.listFiles(); for (File file : files) { String fullName = file.getName(); String ext = getExtension(fullName); String ip = rmvExtension(fullName); if (!ext.equals(logFileExt) || ip.length() == 0) { continue; } LoggerMessage data = null; try { System.out.println(file.toString()); String json = FileUtils.readFileToString(file, null); data = LoggerMessage.fromJSON(json); } catch (Exception e) { System.out.println("Failed to parse file: " + fullName + " ERROR: " + e.getMessage()); continue; } //data is verified at this point LoggerMessage rec = logStore.get(ip); if (rec == null) { logStore.put(ip, data); } else { rec.getLogs().addAll(data.getLogs()); } storeSize += data.getLogs().size(); fileLoadCount++; } System.out.println( "Initialization complete. Files loaded: " + fileLoadCount + " Total logs loaded: " + storeSize); }
From source file:org.gyt.schema.json.Utils.java
public static JsonNode loadResource(final File file) throws IOException { System.out.println("[FILE] " + file.getName()); return JsonLoader.fromFile(file); }
From source file:com.aurel.track.plugin.JavaScriptPathExtenderAction.java
public static String getDirs() { List<File> dirs = PluginUtils.getJavaScriptExtensionDirs(); if (dirs == null || dirs.isEmpty()) { return ""; }/*from w w w. jav a 2 s .c o m*/ StringBuffer pathMappings = new StringBuffer(); for (File dir : dirs) { String nameSpace = dir.getName(); String path = dir.getAbsolutePath(); //for ex. if a plugin name is 'reportPlugin' then: Ext.Loader.setPath('reportPlugin', 'loadJavaScript!load.action?file=reportPlugin/js'); //that means all js files defined in plugin should be defined as Ext.define('reportPlugin.<ReportConfigJSName>',{...}) pathMappings.append("Ext.Loader.setPath('" + nameSpace + "', 'loadJavaScript.action?pluginDir=" + nameSpace + "&file=');\n"); } return pathMappings.toString(); }
From source file:hudson.init.InitScriptsExecutor.java
@Initializer(after = JOB_LOADED) public static void init(Hudson hudson) throws IOException { URL bundledInitScript = hudson.servletContext.getResource("/WEB-INF/init.groovy"); if (bundledInitScript != null) { logger.info("Executing bundled init script: " + bundledInitScript); InputStream in = bundledInitScript.openStream(); try {//from www. j a v a 2 s .c o m String script = IOUtils.toString(in); logger.info(new Script(script).execute()); } finally { IOUtils.closeQuietly(in); } } File initScript = new File(hudson.getRootDir(), "init.groovy"); if (initScript.exists()) { execute(initScript); } File initScriptD = new File(hudson.getRootDir(), "init.groovy.d"); if (initScriptD.isDirectory()) { File[] scripts = initScriptD.listFiles(new FileFilter() { @Override public boolean accept(File f) { return f.getName().endsWith(".groovy"); } }); if (scripts != null) { // sort to run them in a deterministic order Arrays.sort(scripts); for (File f : scripts) { execute(f); } } } }
From source file:io.proleap.cobol.runner.impl.CobolParseTestRunnerImpl.java
protected static boolean isCobolFile(final File inputFile) { final String extension = FilenameUtils.getExtension(inputFile.getName()).toLowerCase(); return inputFile.isFile() && Arrays.asList(cobolFileExtensions).contains(extension); }
From source file:com.alvermont.terraj.fracplanet.io.FileUtils.java
/** * Set the extension of the filename of a <code>File</code> object. If * an extension is already present then it is replaced by the one * specified.//from www . ja v a 2s . c o m * * @param f The file to have its extension modified * @param newExt The new extension to be given e.g. ".pov" * @return A new file object with the name having the specified extension */ public static File changeExtension(File f, String newExt) { File file = f; String name = file.getName(); final int pos = name.lastIndexOf("."); if (pos < 0) { return addExtension(file, newExt); } else { name = name.substring(0, pos); if (!newExt.startsWith(".")) { name += "."; } name += newExt; file = new File(file.getParentFile(), name); } return file; }
From source file:com.mgmtp.perfload.loadprofiles.ui.util.SwingUtils.java
public static JFileChooser createFileChooser(final File dir, final String description, final String extension) { JFileChooser fc = new JFileChooser(dir); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(false);/*from w w w .j a v a2 s . c om*/ fc.setAcceptAllFileFilterUsed(false); fc.addChoosableFileFilter(new FileFilter() { @Override public String getDescription() { return description; } @Override public boolean accept(final File f) { return f.isDirectory() || FilenameUtils.isExtension(f.getName(), extension); } }); return fc; }
From source file:com.alibaba.jstorm.utils.PathUtils.java
public static List<String> read_dir_contents(String dir) { ArrayList<String> rtn = new ArrayList<String>(); if (exists_file(dir)) { File[] list = (new File(dir)).listFiles(); for (File f : list) { rtn.add(f.getName()); }//from w ww. jav a 2s .co m } return rtn; }
From source file:com.msg.wmTestHelper.file.NameExtractor.java
public static ProcessFile extractProcessFile(File processFile) { ProcessFile result = new ProcessFile(); String[] varNameParts = processFile.getName().split("[.]"); Validate.validIndex(varNameParts, 2); if (isFiltered(varNameParts[2])) { return null; }/* w w w . ja v a2 s . co m*/ result.fileReference(processFile).version(getVersion(varNameParts)).name(getName(varNameParts)); return result; }
From source file:com.mycompany.hdp.hdp.java
private static void copyFilesToDir(String srcDirPath, FileSystem fs, String destDirPath) throws IOException { File dir = new File(srcDirPath); for (File file : dir.listFiles()) { fs.copyFromLocalFile(new Path(file.getPath()), new Path(destDirPath, file.getName())); }/*from w w w. j ava 2 s. c o m*/ }