public void loadProperty() { try { File file = new File(confFileName); log.debug("file=" + file.getAbsolutePath()); confProperties = new Properties(); confProperties.loadFromXML(new FileInputStream(file)); bonitaApiHost = confProperties.getProperty("bonita.api.host"); bonitaApiUsername = confProperties.getProperty("bonita.api.username"); bonitaApiPassword = confProperties.getProperty("bonita.api.password"); bonitaApiHttpUsername = confProperties.getProperty("bonita.api.http.username"); bonitaApiHttpPassword = confProperties.getProperty("bonita.api.http.password"); bonitaApiPath = confProperties.getProperty("bonita.api.path"); rallyApiHost = confProperties.getProperty("rally.api.host"); rallyApiHttpUsername = confProperties.getProperty("rally.api.http.username"); rallyApiHttpPassword = confProperties.getProperty("rally.api.http.password"); rallyProjectIds = confProperties.getProperty("rally.project.ids"); // bonitaProcessId=properties.getProperty("bonita.process.xp_code.id"); workflowServiceUrl = confProperties.getProperty("service.url"); } catch (Exception e) { log.error("", e); } }
/** * Get dependencies of a source file. * * @param path The canonical path of source file. * @return Path of dependencies. */ private ArrayList<String> getDependencies(String path) { if (!dependenceMap.containsKey(path)) { ArrayList<String> dependencies = new ArrayList<String>(); Matcher m = PATTERN_REQUIRE.matcher(read(path, charset)); while (m.find()) { // Decide which root path to use. // Path wrapped in <> is related to root path. // Path wrapped in "" is related to parent folder of the source file. String root = null; if (m.group(1).equals("<")) { root = this.root; } else { root = new File(path).getParent(); } // Get path of required file. String required = m.group(2); File f = new File(root, required); if (f.exists()) { dependencies.add(canonize(f)); } else { App.exit("Cannot find required file " + required + " in " + path); } } dependenceMap.put(path, dependencies); } return dependenceMap.get(path); }
/** * The ActionListener implementation * * @param event the event. */ public void actionPerformed(ActionEvent event) { String searchText = textField.getText().trim(); if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) { textPane.setText("Blank search text is not allowed for large IdTables."); } else { File outputFile = null; if (saveAs.isSelected()) { outputFile = chooser.getSelectedFile(); if (outputFile != null) { String name = outputFile.getName(); int k = name.lastIndexOf("."); if (k != -1) name = name.substring(0, k); name += ".txt"; File parent = outputFile.getAbsoluteFile().getParentFile(); outputFile = new File(parent, name); chooser.setSelectedFile(outputFile); } if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0); outputFile = chooser.getSelectedFile(); } textPane.setText(""); Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile); searcher.start(); } }
public void checkPrintFiles() { LinkedHashMap<String, File> nameFile = new LinkedHashMap<String, File>(); nameFile.put("Reference directory", referenceDir); nameFile.put("Pipeline.jar", pJar); nameFile.put("Pipeline properties", truncPipePropFile); nameFile.put("Coverage QC bed", bedForCoverageQC); nameFile.put("Variant calling bed", bedForVarCalling); nameFile.put("Fasta genome reference", fastaReference); nameFile.put("Unfiltered bam", unfilteredBam); nameFile.put("Final bam", finalBam); nameFile.put("Final vcf", finalVcf); if (webRootForLinks != null) nameFile.put("Web links dir", webRootForLinks); nameFile.put("Final output dir", outputDirectory); boolean missingFile = false; System.out.println("\nResources (name exists path):"); for (String name : nameFile.keySet()) { File f = nameFile.get(name); boolean fExists = true; if (f == null) { fExists = false; missingFile = true; } else { fExists = f.exists(); if (fExists == false) missingFile = true; } System.out.println(name + "\t" + fExists + "\t" + f); } if (missingFile) Misc.printErrAndExit("\nMissing resources! See above."); }
public boolean accept(File pathname) { if (pathname.isDirectory()) { return true; } else { return pattern.matcher(pathname.getName()).matches(); } }
public static BufferedReader getBufferedReader(String fileName, String context) throws Throwable { includeNames.add(fileName); if (fileName.startsWith("http://") || fileName.startsWith("https://")) { String hashedFileName = MD5(fileName); File remoteCacheFile = new File(cacheDirectoryName + File.separator + hashedFileName); if (remoteCacheFile.exists()) { return new BufferedReader(new FileReader(remoteCacheFile)); } else { URL input = new URL(fileName); BufferedReader remoteReader = new BufferedReader(new InputStreamReader(input.openStream())); BufferedWriter cacheWriter = new BufferedWriter( new FileWriter(cacheDirectoryName + File.separator + hashedFileName)); String tmpLine = remoteReader.readLine(); while (tmpLine != null) { cacheWriter.write(tmpLine); cacheWriter.newLine(); tmpLine = remoteReader.readLine(); } cacheWriter.close(); return new BufferedReader( new FileReader(cacheDirectoryName + File.separator + hashedFileName)); } } else { if (fileName.startsWith(context)) { return new BufferedReader(new FileReader(fileName)); } else { return new BufferedReader(new FileReader(context + fileName)); } } }
public String fetchCleanupReviewDirLinkGenXml() { String s = null; try { s = // Organize and Clean Up Section "<ReviewDirGenerator class='operator.ReviewDirGenerator' destination.dir='" + outputDirectory.getCanonicalPath() + "' sample='" + outputDirectory.getName() + "' submitter='" + submitter + "' analysis.type='" + analysisType + "'> \n" + " <finalVariants /> \n" + " <ViewerCSV /> \n" + " <InstanceLog class='buffer.InstanceLogFile' /> \n" + " <finalBAM /> \n" + " <QCOutputFile /> \n" + " <bedForVars /> \n" + "</ReviewDirGenerator> \n\n"; } catch (IOException e) { e.printStackTrace(); Misc.printErrAndExit("\nError fetching clean up and review dir links.\n"); } return s; }
public void actionPerformed(ActionEvent e) { if (readOnly) { return; } JFileChooser fc = getFileChooser(); File currentDirectory = fc.getCurrentDirectory(); if (!currentDirectory.exists()) { JOptionPane.showMessageDialog( fc, newFolderParentDoesntExistText, newFolderParentDoesntExistTitleText, JOptionPane.WARNING_MESSAGE); return; } File newFolder; try { newFolder = fc.getFileSystemView().createNewFolder(currentDirectory); if (fc.isMultiSelectionEnabled()) { fc.setSelectedFiles(new File[] {newFolder}); } else { fc.setSelectedFile(newFolder); } } catch (IOException exc) { JOptionPane.showMessageDialog( fc, newFolderErrorText + newFolderErrorSeparator + exc, newFolderErrorText, JOptionPane.ERROR_MESSAGE); return; } fc.rescanCurrentDirectory(); }
void put(final URI uri, ArtifactData data) throws Exception { reporter.trace("put %s %s", uri, data); File tmp = createTempFile(repoDir, "mtp", ".whatever"); tmp.deleteOnExit(); try { copy(uri.toURL(), tmp); byte[] sha = SHA1.digest(tmp).digest(); reporter.trace("SHA %s %s", uri, Hex.toHexString(sha)); ArtifactData existing = get(sha); if (existing != null) { reporter.trace("existing"); xcopy(existing, data); return; } File meta = new File(repoDir, Hex.toHexString(sha) + ".json"); File file = new File(repoDir, Hex.toHexString(sha)); rename(tmp, file); reporter.trace("file %s", file); data.file = file.getAbsolutePath(); data.sha = sha; data.busy = false; CommandData cmddata = parseCommandData(data); if (cmddata.bsn != null) { data.name = cmddata.bsn + "-" + cmddata.version; } else data.name = Strings.display(cmddata.title, cmddata.bsn, cmddata.name, uri); codec.enc().to(meta).put(data); reporter.trace("TD = " + data); } finally { tmp.delete(); reporter.trace("puted %s %s", uri, data); } }
@Override public void actionPerformed(ActionEvent e) { if (td.getTabCount() > 0) { JFileChooser f = new JFileChooser(); f.setFileFilter(new MyFileFilter()); int choose = f.showSaveDialog(getContentPane()); if (choose == JFileChooser.APPROVE_OPTION) { BufferedWriter brw = null; try { File file = f.getSelectedFile(); brw = new BufferedWriter(new FileWriter(file)); int i = td.getSelectedIndex(); TextDocument ta = (TextDocument) td.getComponentAt(i); ta.write(brw); ta.fileName = file.getName(); // 將檔案名稱更新為存檔的名稱 td.setTitleAt(td.getSelectedIndex(), ta.fileName); ta.file = file; ta.save = true; // 設定已儲存 System.out.println("Save as pass!"); td.setTitleAt(i, ta.fileName); // 更新標題名稱 } catch (Exception exc) { exc.printStackTrace(); } finally { try { brw.close(); } catch (Exception ecx) { ecx.printStackTrace(); } } } } else { JOptionPane.showMessageDialog(null, "沒有檔案可以儲存!"); } }
private byte[] loadClassData(String className) throws IOException { Playground.println("Loading class " + className + ".class", warning); File f = new File(System.getProperty("user.dir") + "/" + className + ".class"); byte[] b = new byte[(int) f.length()]; new FileInputStream(f).read(b); return b; }
@Override public void actionPerformed(ActionEvent e) { JFileChooser f = new JFileChooser(); f.setFileFilter(new MyFileFilter()); // 設定檔案選擇器 int choose = f.showOpenDialog(getContentPane()); // 顯示檔案選取 if (choose == JFileChooser.OPEN_DIALOG) { // 有開啟檔案的話,開始讀檔 BufferedReader br = null; try { File file = f.getSelectedFile(); br = new BufferedReader(new FileReader(file)); TextDocument ta = new TextDocument(file.getName(), file); ta.addKeyListener(new SystemTrackSave()); ta.read(br, null); td.add(ta); td.setTitleAt(docCount++, file.getName()); } catch (Exception exc) { exc.printStackTrace(); } finally { try { br.close(); } catch (Exception ecx) { ecx.printStackTrace(); } } } }
private static void tryResUrls(Picture picture) { String hi_res = ""; String url = picture.media_url.toString(); for (String ending : Main.endings) { try { hi_res = url.replace(url.substring(url.lastIndexOf("_"), url.lastIndexOf(".")), ending); URL hi_url = new URL(hi_res); File hi_name = Helper.extractMediaFileNameFromURL(hi_url); if (hi_name.equals(picture.media_name)) { picture.hi_url = hi_url; picture.hi_name = hi_name; picture.downloaded_hi = true; break; } else { boolean success = Helper.downloadFileFromURLToFileInTemp(hi_url, hi_name); if (success) { picture.hi_url = hi_url; picture.hi_name = hi_name; picture.downloaded_hi = true; Helper.moveTempImageToStore(hi_name, new File(Main.blogdir, picture.md5_id)); break; } } } catch (MalformedURLException ex) { Main.error(String.format("Attempted hi res url %s is a malformed URL.", hi_res)); } } }
public static File directoryOf(Class clazz) { File location = locationOf(clazz); if (location.isDirectory()) { return location; } return location.getParentFile(); }
private Service getService(File base) throws Exception { File dataFile = new File(base, "data"); if (!dataFile.isFile()) return null; ServiceData data = getData(ServiceData.class, dataFile); return new Service(this, data); }
public static void main(String[] args) { File path = new File("."); String[] list; if (args.length == 0) list = path.list(); else list = path.list(new DirFilter(args[0])); Arrays.sort(list, String.CASE_INSENSITIVE_ORDER); for (String dirItem : list) System.out.println(dirItem); }
public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { JFileChooser chooser = getFileChooser(); FileSystemView fsv = chooser.getFileSystemView(); JList list = (JList) evt.getSource(); int fsm = chooser.getFileSelectionMode(); boolean useSetDirectory = usesSingleFilePane && (fsm == JFileChooser.FILES_ONLY); if (chooser.isMultiSelectionEnabled()) { File[] files = null; Object[] objects = list.getSelectedValues(); if (objects != null) { if (objects.length == 1 && ((File) objects[0]).isDirectory() && chooser.isTraversable(((File) objects[0])) && (useSetDirectory || !fsv.isFileSystem(((File) objects[0])))) { setDirectorySelected(true); setDirectory(((File) objects[0])); } else { ArrayList<File> fList = new ArrayList<File>(objects.length); for (Object object : objects) { File f = (File) object; boolean isDir = f.isDirectory(); if ((chooser.isFileSelectionEnabled() && !isDir) || (chooser.isDirectorySelectionEnabled() && fsv.isFileSystem(f) && isDir)) { fList.add(f); } } if (fList.size() > 0) { files = fList.toArray(new File[fList.size()]); } setDirectorySelected(false); } } chooser.setSelectedFiles(files); } else { File file = (File) list.getSelectedValue(); if (file != null && file.isDirectory() && chooser.isTraversable(file) && (useSetDirectory || !fsv.isFileSystem(file))) { setDirectorySelected(true); setDirectory(file); if (usesSingleFilePane) { chooser.setSelectedFile(null); } } else { setDirectorySelected(false); if (file != null) { chooser.setSelectedFile(file); } } } } }
public boolean accept(File f) { if (f == null) { return false; } if (f.isDirectory()) { return true; } return pattern.matcher(f.getName()).matches(); }
public boolean accept(File f) { if (f.isDirectory()) { return true; } String fn = f.getName(); if (fn.toLowerCase().endsWith(".java") || fn.toLowerCase().endsWith(".txt")) { return true; } return false; }
public void init(Editor _editor) { this.m_editor = _editor; File toolRoot = null; try { toolRoot = new File( SequantoAutomationTool.class .getProtectionDomain() .getCodeSource() .getLocation() .toURI()) .getParentFile() .getParentFile(); } catch (java.net.URISyntaxException ex) { toolRoot = new File( SequantoAutomationTool.class .getProtectionDomain() .getCodeSource() .getLocation() .getPath()) .getParentFile() .getParentFile(); } m_generatorPy = new File(new File(toolRoot, "generator"), "generate_automation_defines.py") .getAbsolutePath(); m_isWindows = System.getProperty("os.name").toLowerCase().contains("win"); if (m_isWindows) { for (File root : File.listRoots()) { File[] files = root.listFiles( new FileFilter() { public boolean accept(File f) { return f.getName().toLowerCase().startsWith("python"); } }); if (files != null) { for (File directory : files) { m_pythonPath = new File(directory, "python.exe"); break; } } } if (m_pythonPath == null) { Base.showMessage( "ERROR", String.format( "Could not python interpreter - Generate Automation tool will not work.")); } } }
private void checkForGzippedVcf() { String vcfName = finalVcf.getName(); if (vcfName.endsWith(".gz")) { File uncomp = new File(finalVcf.getParentFile(), vcfName.substring(0, vcfName.length() - 3)); if (uncomp.exists() == false) { deleteTempVcf = true; if (IO.uncompress(finalVcf, uncomp) == null) Misc.printErrAndExit("ERROR: failed to uncompress -> " + finalVcf); } finalVcf = uncomp; } }
public String _isdir(String args[]) { if (args.length < 2) { domain.warning("Need at least one file name for ${isdir;...}"); return null; } boolean isdir = true; for (int i = 1; i < args.length; i++) { File f = new File(args[i]).getAbsoluteFile(); isdir &= f.isDirectory(); } return isdir ? "true" : "false"; }
public static File getBuildFolder(Sketch data) throws IOException { File buildFolder; if (PreferencesData.get("build.path") != null) { buildFolder = BaseNoGui.absoluteFile(PreferencesData.get("build.path")); Files.createDirectories(buildFolder.toPath()); } else { buildFolder = FileUtils.createTempFolder("build", DigestUtils.md5Hex(data.getMainFilePath()) + ".tmp"); DeleteFilesOnShutdown.add(buildFolder); } return buildFolder; }
@Nonnull private static File getOutputFileCreatingDirIfNeeded( @Nonnull String outputDir, @Nonnull String sourceFilePath) { File outputFile = getOutputFile(outputDir, sourceFilePath); File parentDir = outputFile.getParentFile(); if (!parentDir.exists()) { boolean outputDirCreated = parentDir.mkdirs(); assert outputDirCreated : "Failed to create output dir: " + outputDir; } return outputFile; }
public List<CommandData> getCommands(File commandDir) throws Exception { List<CommandData> result = new ArrayList<CommandData>(); if (!commandDir.exists()) { return result; } for (File f : commandDir.listFiles()) { CommandData data = getData(CommandData.class, f); if (data != null) result.add(data); } return result; }
private ArrayList GetFolderTree(String s_Dir, String s_Flag, int n_Indent, int n_TreeIndex) { String s_List = ""; ArrayList aSubFolders = new ArrayList(); File file = new File(s_Dir); File[] filelist = file.listFiles(); if (filelist != null && filelist.length > 0) { for (int i = 0; i < filelist.length; i++) { if (filelist[i].isDirectory()) { aSubFolders.add(filelist[i].getName()); } } int n_Count = aSubFolders.size(); String s_LastFlag = ""; String s_Folder = ""; for (int i = 1; i <= n_Count; i++) { if (i < n_Count) { s_LastFlag = "0"; } else { s_LastFlag = "1"; } s_Folder = aSubFolders.get(i - 1).toString(); s_List = s_List + "arr" + s_Flag + "[" + String.valueOf(n_TreeIndex) + "]=new Array(\"" + s_Folder + "\"," + String.valueOf(n_Indent) + ", " + s_LastFlag + ");\n"; n_TreeIndex = n_TreeIndex + 1; ArrayList a_Temp = GetFolderTree(s_Dir + s_Folder + sFileSeparator, s_Flag, n_Indent + 1, n_TreeIndex); s_List = s_List + a_Temp.get(0).toString(); n_TreeIndex = Integer.valueOf(a_Temp.get(1).toString()).intValue(); } } ArrayList a_Return = new ArrayList(); a_Return.add(s_List); a_Return.add(String.valueOf(n_TreeIndex)); return a_Return; }
/** * Takes a line and looks for an archive group tag. If one is found, the information from the tag * is returned as an <CODE>ArchiveGroup</CODE>. If a tag is found, the data in the tag is stored * in the <CODE>HashMap</CODE> provided. * * @param currentLine The line in which to look for the archive tag. * @param template The <CODE>Template</CODE> to which the <CODE>ArchiveGroup</CODE> belongs. * @return The archive request tag data as an instance of <CODE>ArchiveGroup</CODE>, <CODE>null * </CODE> if the line passed in does not contain an arFile tag. */ private ArchiveGroup parseArchiveGroupTag(String currentLine, Template template) { ArchiveGroup archiveTag; Matcher currentMatcher = archiveRequestPattern.matcher(currentLine); if (currentMatcher.find()) { String fileName = currentMatcher.group(1); archiveTag = template.getArchiveGroup(fileName); if (archiveTag == null) { File groupFile = new File(fileName); archiveTag = new ArchiveGroup(groupFile.getParent(), groupFile.getName()); template.addArchiveGroup(archiveTag); } } else archiveTag = null; return archiveTag; }
public String _fmodified(String args[]) throws Exception { verifyCommand(args, _fmodifiedHelp, null, 2, Integer.MAX_VALUE); long time = 0; Collection<String> names = new ArrayList<String>(); for (int i = 1; i < args.length; i++) { Processor.split(args[i], names); } for (String name : names) { File f = new File(name); if (f.exists() && f.lastModified() > time) time = f.lastModified(); } return "" + time; }
public List<ServiceData> getServices(File serviceDir) throws Exception { List<ServiceData> result = new ArrayList<ServiceData>(); if (!serviceDir.exists()) { return result; } for (File sdir : serviceDir.listFiles()) { File dataFile = new File(sdir, "data"); ServiceData data = getData(ServiceData.class, dataFile); result.add(data); } return result; }
String ls(String args[], boolean relative) { if (args.length < 2) throw new IllegalArgumentException( "the ${ls} macro must at least have a directory as parameter"); File dir = domain.getFile(args[1]); if (!dir.isAbsolute()) throw new IllegalArgumentException( "the ${ls} macro directory parameter is not absolute: " + dir); if (!dir.exists()) throw new IllegalArgumentException( "the ${ls} macro directory parameter does not exist: " + dir); if (!dir.isDirectory()) throw new IllegalArgumentException( "the ${ls} macro directory parameter points to a file instead of a directory: " + dir); Collection<File> files = new ArrayList<File>(new SortedList<File>(dir.listFiles())); for (int i = 2; i < args.length; i++) { Instructions filters = new Instructions(args[i]); files = filters.select(files, true); } List<String> result = new ArrayList<String>(); for (File file : files) result.add(relative ? file.getName() : file.getAbsolutePath()); return Processor.join(result, ","); }