private boolean FS_PeakClusterRead() { if (!new File(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS").exists()) { return false; } try { Logger.getRootLogger().info("Reading PeakCluster serialization from file:" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS..."); FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(ParentmzXMLName) + FilenameUtils.getBaseName(ParentmzXMLName) + "_Peak/" + FilenameUtils.getBaseName(ScanCollectionName) + "_PeakCluster.serFS"); FSTObjectInput in = new FSTObjectInput(fileIn); PeakClusters = (ArrayList<PeakCluster>) in.readObject(); in.close(); fileIn.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); if (FS_PeakClusterRead_Old()) { WritePeakClusterSerialization(); return true; } Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return false; } return true; }
private boolean FSWrite(String filepath, String tag) { try { if (!tag.equals("")) { tag = "_" + tag; } Logger.getRootLogger().info("Writing ID results to file:" + FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + tag + "_LCMSID.serFS..."); FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(filepath) + FilenameUtils.getBaseName(filepath) + tag + "_LCMSID.serFS", false); FSTObjectOutput out = new FSTObjectOutput(fout); ReduceMemoryUsage(); out.writeObject(this, LCMSID.class); out.close(); fout.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return false; } return true; }
@Test public void testCustomizeServletContainer() { env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION); UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory(); webConfigurer.customize(container); assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg"); assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8"); assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8"); if (container.getDocumentRoot() != null) { assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("target/www")); } Builder builder = Undertow.builder(); container.getBuilderCustomizers().forEach(c -> c.customize(builder)); OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions"); assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull(); }
/** * Creates a new DocsPage instance. * * @param project The project this page belongs to. * @param title The title of this page. * @param language The language of this page. * @param file The file (HTML or MarkDown) that represents the content of this page. */ public DocsPage(final DocsProject project, final File file) { final Map<String, Object> header = Utils.decodeFileHeader(Utils.separateFileHeader(file)[0]); this.project = project; this.title = header != null && header.containsKey(Constants.KEY_HEADER_TITLE) ? header.get(Constants.KEY_HEADER_TITLE).toString() : StringUtils.capitalize(FilenameUtils.removeExtension(file.getName())); this.language = header != null && header.containsKey(Constants.KEY_HEADER_LANGUAGE) ? header.get(Constants.KEY_HEADER_LANGUAGE).toString() : project.getDefaultLanguage(); this.absolutePath = file.getPath(); this.path = absolutePath.replace(project.getContentDirectory().getPath(), "").replace(project.getBuildDirectory().getPath(), ""); this.relativeURL = getBuildDestination().getPath().replace(project.getBuildDirectory().getPath(), "").replace(File.separator, "/"); if(header != null) { if(header.containsKey(Constants.KEY_HEADER_PREVIOUS)) { this.previous = header.get(Constants.KEY_HEADER_PREVIOUS).toString(); } if(header.containsKey(Constants.KEY_HEADER_NEXT)) { this.next = header.get(Constants.KEY_HEADER_NEXT).toString(); } this.header.putAll(header); } }
/** * 缩略图文件URL/ID编辑 <br> * 取原图 * * @param thumbUrl 缩略图 * @return 原图URL */ public static String getOrgiUrl(String thumbUrl) { if (thumbUrl == null) { return null; } String extension = FilenameUtils.getExtension(thumbUrl); if (extension == null) { return thumbUrl; } if ("jpg".equalsIgnoreCase(extension)) { // 缩略图 } else if ("png".equalsIgnoreCase(extension)) { // 缩略图 } else { return thumbUrl; } return thumbUrl.replaceAll("_\\d+x\\d+\\." + extension + "$", "." + extension); }
public static TargetMatchScoring LibraryMatchRead(String Filename, String LibID) throws FileNotFoundException { if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS").exists()) { return null; } TargetMatchScoring match = null; try { Logger.getRootLogger().info("Loading Target library match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS..."); FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS"); FSTObjectInput in = new FSTObjectInput(fileIn); match = (TargetMatchScoring) in.readObject(); in.close(); fileIn.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return null; } return match; }
public void exportImage() { try { File file = IOUtility.selectFileToSave(FileType.IMAGE); if (file != null) { Rectangle drawingArea = getDrawingArea(); String extension = FilenameUtils.getExtension(file.getName()); if (extension.equals("svg")) { SVGGraphics2D svgGenerator = IOUtility.getSVGGraphics(drawingArea.getSize()); paintDrawing(svgGenerator, drawingArea.x, drawingArea.y); svgGenerator.stream(new FileWriter(file)); svgGenerator.dispose(); } else { BufferedImage bi = new BufferedImage(drawingArea.width, drawingArea.height, BufferedImage.TYPE_INT_RGB); Graphics g = bi.createGraphics(); paintDrawing(g, drawingArea.x, drawingArea.y); ImageIO.write(bi, extension, file); g.dispose(); } } } catch (Exception e) { e.printStackTrace(); } }
public ImageResource createImageResource(MultipartFile loResImage, MultipartFile hiResImage, Boolean dryRun) throws IOException, BuenOjoFileException, BuenOjoInconsistencyException { ImageResource imageResource = new ImageResource(); if (loResImage!=null) { if (imageResource.getName()==null) imageResource.setName(FilenameUtils.removeExtension(loResImage.getOriginalFilename())); imageResource.setLoResImage(loResImage.getBytes()); imageResource.setLoResImageContentType(loResImage.getContentType()); } if (hiResImage != null){ if (imageResource.getName()==null) imageResource.setName(FilenameUtils.removeExtension(hiResImage.getOriginalFilename())); imageResource.setHiResImage(hiResImage.getBytes()); imageResource.setHiResImageContentType(hiResImage.getContentType()); } return createImageResource(imageResource,dryRun); }
private void Parse() throws FileNotFoundException, IOException { //806.080993652344,8429.974609375,1 //832.287536621094,7226.927734375,1 //854.039978027344,6682.37646484375,1 //861.061340332031,8370.4716796875,1 BufferedReader reader = new BufferedReader(new FileReader(filename)); String line = ""; String[] Values = null; scan = new ScanData(); scan.MGFTitle = FilenameUtils.getBaseName(filename); while ((line = reader.readLine()) != null) { if ((Values = line.split(",")).length == 3) { scan.AddPoint(Float.parseFloat(Values[0]), Float.parseFloat(Values[1])); } } reader.close(); }
public static Optional<String> contentType(Path path) { String extension = FilenameUtils.getExtension(path.getFileName().toString()); switch (extension.toLowerCase()) { case "jpeg": return Optional.of("image/jpeg"); case "jpg": return Optional.of("image/jpg"); case "png": return Optional.of("image/png"); case "gif": return Optional.of("image/gif"); case "tif": case "tiff": return Optional.of("image/tiff"); case "csv": return Optional.of("text/csv"); default: return Optional.empty(); } }
public ClusterConfigurationService(Cache cache) throws IOException { this.cache = (GemFireCacheImpl) cache; Properties properties = cache.getDistributedSystem().getProperties(); // resolve the cluster config dir String clusterConfigRootDir = properties.getProperty(CLUSTER_CONFIGURATION_DIR); if (StringUtils.isBlank(clusterConfigRootDir)) { clusterConfigRootDir = System.getProperty("user.dir"); } else { File diskDir = new File(clusterConfigRootDir); if (!diskDir.exists() && !diskDir.mkdirs()) { throw new IOException("Cannot create directory : " + clusterConfigRootDir); } clusterConfigRootDir = diskDir.getCanonicalPath(); } // resolve the file paths String configDiskDirName = CLUSTER_CONFIG_DISK_DIR_PREFIX + cache.getDistributedSystem().getName(); configDirPath = FilenameUtils.concat(clusterConfigRootDir, CLUSTER_CONFIG_ARTIFACTS_DIR_NAME); configDiskDirPath = FilenameUtils.concat(clusterConfigRootDir, configDiskDirName); sharedConfigLockingService = getSharedConfigLockService(cache.getDistributedSystem()); status.set(SharedConfigurationStatus.NOT_STARTED); }
private static int[] loadFile(File file) throws IOException { String ext = FilenameUtils.getExtension(file.getName()); try (InputStream is = new FileInputStream(file)) { if ("zip".equalsIgnoreCase(ext)) { try (ZipInputStream zis = new ZipInputStream(is)) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { String name = entry.getName(); String entryExt = FilenameUtils.getExtension(name); if (Stream.of("gb", "gbc", "rom").anyMatch(e -> e.equalsIgnoreCase(entryExt))) { return load(zis, (int) entry.getSize()); } zis.closeEntry(); } } throw new IllegalArgumentException("Can't find ROM file inside the zip."); } else { return load(is, (int) file.length()); } } }
@PostConstruct public void init() { try { File mailFolder = resourceService.getClasspathResource(TEMPLATE_FOLDER_NAME); if (!mailFolder.isFile()) { File[] mailFolderArray = mailFolder.listFiles(); for (File mailTemplateFile : mailFolderArray) { String mailTemplateName = FilenameUtils.getBaseName(mailTemplateFile.getName()); String mailTemplatePath = TEMPLATE_FOLDER_NAME + File.separator + mailTemplateFile.getName(); mailTemplateMap.put(mailTemplateName, mailTemplatePath); } } } catch (Exception e) { LOG.error(e.getMessage(), e); } }
/** * Detects the filetype of the selected output file based on the file extension and selects radio buttons accordingly * @param fileName String with the filename of the selected output file * @return */ private String setFileType(String fileName) { String ext = FilenameUtils.getExtension(fileName); System.out.println("FT: " + ext); switch (ext) { case "png": imgRadioPng.setSelected(true); break; case "jpg": imgRadioJpg.setSelected(true); break; case "jpeg": imgRadioJpg.setSelected(true); break; case "gif": imgRadioGif.setSelected(true); break; default: System.out.println("No Correct File Ending"); break; } return ext; }
private static void SaintOutput(LCMSID protID, LCMSID IDsummary, FragmentSelection fragselection, FileWriter interactionfile, String filename, String samplename, HashMap<String, String> PreyID, int quanttype) throws IOException { for (String key : protID.ProteinList.keySet()) { if (IDsummary.ProteinList.containsKey(key)) { ProtID protein = IDsummary.ProteinList.get(key); float abundance = 0f; if (quanttype == 1) { abundance = protein.GetAbundanceByMS1_IBAQ(); } else if (quanttype == 2) { abundance = protein.GetAbundanceByTopCorrFragAcrossSample(fragselection.TopPeps.get(protein.getAccNo()), fragselection.TopFrags); } if (abundance > 0) { interactionfile.write(FilenameUtils.getBaseName(filename) + "\t" + samplename + "\t" + protein.getAccNo() + "\t" + abundance + "\n"); if (!PreyID.containsKey(protein.getAccNo())) { PreyID.put(protein.getAccNo(), /*protein.Sequence.length()+"\t"+*/ protein.GetGeneName()); } } } } }
public KnowledgeBaseType inferKnowledgeBaseType(ScriptKnowledgeBase scriptKnowledgeBase) { List<KnowledgeBaseScript> scripts = scriptKnowledgeBase.getScripts(); if (scripts.isEmpty()) { throw new SpongeException("Cannot infer knowledge base '" + scriptKnowledgeBase.getName() + "' type because it has no files"); } String fileName = scripts.get(0).getFileName(); String extension = FilenameUtils.getExtension(fileName); Optional<KnowledgeBaseType> typeO = knowledgeBaseInterpreterFactories.values().stream() .filter(factory -> StringUtils.equalsIgnoreCase(factory.getSupportedType().getFileExtension(), extension)) .map(factory -> factory.getSupportedType()).findFirst(); if (!typeO.isPresent()) { throw new SpongeException("Unsupported file extension '" + extension + "' for file '" + fileName + "' in knowledge base '" + scriptKnowledgeBase.getName() + "'"); } return typeO.get(); }
@Test public void compile() { testRunner.ensureDirectory(testRunner.getTmpDir()); testRunner.copySource(new SourceFile(exampleSourceFilename)); testRunner.compile(); // Should have created temp source file File origSource = new File(exampleSourceFilename); String tmpClassFilename = FilenameUtils.removeExtension(origSource.getName()) + ".class"; String tmpTestClassFilename = FilenameUtils.removeExtension(origSource.getName()) + "Test.class"; File tmpClassFile = new File(testRunner.getTmpDir(), tmpClassFilename); File tmpTestClassFile = new File(testRunner.getTmpDir(), tmpTestClassFilename); assertTrue(tmpClassFile.exists()); assertTrue(tmpTestClassFile.exists()); }
/** * Rename existing file on server if there is a conflict. */ @Override public void apply(final Path file, final Local local, final TransferStatus status, final ProgressListener listener) throws BackgroundException { // Rename existing file before putting new file in place if(status.isExists()) { Path rename; do { final String proposal = MessageFormat.format(PreferencesFactory.get().getProperty("queue.upload.file.rename.format"), FilenameUtils.getBaseName(file.getName()), UserDateFormatterFactory.get().getMediumFormat(System.currentTimeMillis(), false).replace(Path.DELIMITER, '-').replace(':', '-'), StringUtils.isNotBlank(file.getExtension()) ? String.format(".%s", file.getExtension()) : StringUtils.EMPTY); rename = new Path(file.getParent(), proposal, file.getType()); } while(find.find(rename)); if(log.isInfoEnabled()) { log.info(String.format("Rename existing file %s to %s", file, rename)); } move.move(file, rename, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback()); if(log.isDebugEnabled()) { log.debug(String.format("Clear exist flag for file %s", file)); } status.setExists(false); } super.apply(file, local, status, listener); }
public File [] getFilesInCurrentDirectory() { if(mAllowedFileExtensionFilter!=null) { FilenameFilter fileNameFilter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { String fileExtension = FilenameUtils.getExtension(name); if(mAllowedFileExtensionFilter.contains(fileExtension) || fileExtension.isEmpty() ) return true; else return false; } }; return mCurrentNode.listFiles(fileNameFilter); } return mCurrentNode.listFiles(); }
/** * Returns an input stream to the image in the given file. If the file is an audio file, * the embedded album art is returned. In addition returns the mime type */ private Pair<InputStream, String> getImageInputStreamWithType(File file) throws IOException { InputStream is; String mimeType; if (jaudiotaggerParser.isApplicable(file)) { LOG.trace("Using Jaudio Tagger for reading artwork from {}", file); MediaFile mediaFile = mediaFileService.getMediaFile(file); Artwork artwork; try { LOG.trace("Reading artwork from file {}", mediaFile); artwork = jaudiotaggerParser.getArtwork(mediaFile); } catch (Exception e) { LOG.debug("Could not read artwork from file {}", mediaFile); throw new RuntimeException(e); } is = new ByteArrayInputStream(artwork.getBinaryData()); mimeType = artwork.getMimeType(); } else { is = new FileInputStream(file); mimeType = StringUtil.getMimeType(FilenameUtils.getExtension(file.getName())); } return Pair.of(is, mimeType); }
public static TargetMatchScoring LibraryMatchReadJS(String Filename, String LibID) throws FileNotFoundException { if (!new File(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS").exists()) { return null; } TargetMatchScoring match = null; try { Logger.getRootLogger().info("Loading Target library match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.ser..."); FileInputStream fileIn = new FileInputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.ser"); ObjectInputStream in = new ObjectInputStream(fileIn); match = (TargetMatchScoring) in.readObject(); in.close(); fileIn.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return null; } return match; }
/** * Returns whether this parser is applicable to the given file. * * @param file The music file in question. * @return Whether this parser is applicable to the given file. */ @Override public boolean isApplicable(File file) { if (!file.isFile()) { return false; } String format = FilenameUtils.getExtension(file.getName()).toLowerCase(); return format.equals("mp3") || format.equals("m4a") || format.equals("aac") || format.equals("ogg") || format.equals("flac") || format.equals("wav") || format.equals("mpc") || format.equals("mp+") || format.equals("ape") || format.equals("wma"); }
private File extractNativeLibraries(final File nativesDirectory, final String libraryPath) { final URL libraryUrl = Thread.currentThread().getContextClassLoader().getResource(libraryPath); if (libraryUrl == null) { throw new IllegalArgumentException( String.format("Unable to find native binary %s for library %s", libraryPath, key)); } final String libraryName; libraryName = FilenameUtils.getName(libraryPath); final File libraryFile = new File(nativesDirectory, libraryName); libraryFile.getParentFile().mkdirs(); try { final URLConnection urlConnection = libraryUrl.openConnection(); try (final InputStream inputStream = urlConnection.getInputStream()) { try (final OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(libraryFile))) { IOUtils.copy(inputStream, outputStream); } } } catch (final Exception exception) { throw new RuntimeException(exception); } if (deleteOnExit) { libraryFile.deleteOnExit(); } // TODO make accessible for linux and mac return libraryFile; }
public static <T extends NativeCompileSpec> File generatePCHSourceFile(T original, File sourceFile) { File generatedSourceDir = new File(original.getTempDir(), "pchGenerated"); generatedSourceDir.mkdirs(); File generatedSource = new File(generatedSourceDir, FilenameUtils.removeExtension(sourceFile.getName()).concat(getSourceFileExtension(original.getClass()))); File headerFileCopy = new File(generatedSourceDir, sourceFile.getName()); try { FileUtils.copyFile(sourceFile, headerFileCopy); FileUtils.writeStringToFile(generatedSource, "#include \"".concat(headerFileCopy.getName()).concat("\"")); return generatedSource; } catch (IOException e) { throw new UncheckedIOException(e); } }
public static String getType(String fileName) { try { return getTypeFor(FilenameUtils.getExtension(fileName)); } catch (Exception ex) { LOG.log(Level.SEVERE, ex.getMessage(), ex); } return null; }
public void GenerateModel() throws IOException { XYPointCollection points = new XYPointCollection(); XYSeries series = new XYSeries("Peptide ions"); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); FileWriter writer = new FileWriter(FilenameUtils.getFullPath(TargetLCMS.mzXMLFileName) + "/" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "_" + libManager.LibID + "_RTMapPoints.txt"); for (String pepkey : libManager.PeptideFragmentLib.keySet()) { if (TargetLCMS.GetPepIonList().containsKey(pepkey)) { PepFragmentLib peplib = libManager.GetFragmentLib(pepkey); for (float rt : peplib.RetentionTime) { float y = TargetLCMS.GetPepIonList().get(pepkey).GetRT(); points.AddPoint(rt, y); series.add(new XYDataItem(rt, y)); writer.write(rt + "\t" + y + "\n"); } } } writer.close(); regression = new PiecewiseRegression(parameter.MaxCurveRTRange, parameter.MaxCurveRTRange); regression.SetData(points); float R2 = regression.GetR2(); Logger.getRootLogger().info("Retention time prediction model:(" + FilenameUtils.getBaseName(TargetLCMS.mzXMLFileName) + "..R2=" + R2 + "(No. of commonly identified peptide ions=" + points.PointCount() + ")"); GenerateRTMapPNG(xySeriesCollection, series, R2); }
private static String getNodeName(URL file, GenerationConfig config) { try { String fileName = FilenameUtils.getName(URLDecoder.decode(file.toString(), "UTF-8")); String[] extensions = config.getFileExtensions(); boolean extensionRemoved = false; for (int i = 0; i < extensions.length; i++) { String extension = extensions[i]; if (extension.length() == 0) { continue; } if (!extension.startsWith(".")) { extension = "." + extension; } if (fileName.endsWith(extension)) { fileName = removeEnd(fileName, extension); extensionRemoved = true; break; } } if (!extensionRemoved) { fileName = FilenameUtils.getBaseName(fileName); } return fileName; } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(String.format("Unable to generate node name from URL: %s", file.toString()), e); } }
/** * resource的路径格式,至少是以这个形式结尾:schemaId.yaml */ public SchemaMeta registerSchema(String microserviceName, Resource resource) { try { String schemaId = FilenameUtils.getBaseName(resource.getFilename()); String swaggerContent = IOUtils.toString(resource.getURL()); SchemaMeta schemaMeta = registerSchema(microserviceName, schemaId, swaggerContent); return schemaMeta; } catch (Throwable e) { throw new Error(e); } }
public boolean LibraryMatchWrite() throws FileNotFoundException { try { Logger.getRootLogger().info("Writing Target match results to file:" + FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS..."); FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(Filename) + FilenameUtils.getBaseName(Filename) + "_" + LibID + "_LibMatch.serFS", false); FSTObjectOutput out = new FSTObjectOutput(fout); out.writeObject(this); out.close(); fout.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); return false; } return true; }
private Void saveAll() { File selectedFile = IOUtility.selectFileToSave(FileType.ONTOLOGY); if (selectedFile != null) { String fileName = FilenameUtils.removeExtension(selectedFile.getAbsolutePath()); for (int i = 0; i < objects.getCount(); i++) { TreeNode node = objects.getNode(i); saveObject(fileName, node.getType(), node.getUserObject()); } } return null; }
public void WriteParamSerialization(String mzXMLFileName) { try { Logger.getRootLogger().info("Writing parameter to file:" + FilenameUtils.getFullPath(mzXMLFileName) + FilenameUtils.getBaseName(mzXMLFileName) + "_params.ser..."); FileOutputStream fout = new FileOutputStream(FilenameUtils.getFullPath(mzXMLFileName) + FilenameUtils.getBaseName(mzXMLFileName) + "_params.ser", false); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(this); oos.close(); fout.close(); } catch (Exception ex) { Logger.getRootLogger().error(ExceptionUtils.getStackTrace(ex)); } }
public void AssignMappedPepQuant() throws SQLException, IOException { if (IDsummary == null || IDsummary.GetMappedPepIonList().isEmpty()) { return; } if (!FilenameUtils.getBaseName(IDsummary.mzXMLFileName).equals(FilenameUtils.getBaseName(ScanCollectionName))) { return; } Logger.getRootLogger().info("Assigning peak cluster to mapped peptide IDs......"); for (PepIonID pepIonID : IDsummary.GetMappedPepIonList().values()) { pepIonID.CreateQuantInstance(MaxNoPeakCluster); ArrayList<PeakCluster> clusterList = FindAllPeakClustersForMappedPep(pepIonID); if (!clusterList.isEmpty()) { PeakCluster targetCluster = null; float Score = 0f; for (int i = 0; i < clusterList.size(); i++) { PeakCluster cluster = clusterList.get(i); if ("".equals(cluster.AssignedPepIon)) { Score = cluster.PeakHeight[0] * cluster.MS1Score; if (targetCluster == null || clusterList.get(i).MS1Score > Score) { targetCluster = cluster; Score = cluster.MS1Score; } } } if (targetCluster != null) { pepIonID.PeakArea = targetCluster.PeakArea; pepIonID.PeakHeight = targetCluster.PeakHeight; pepIonID.MS1PeakClusters.add(targetCluster); pepIonID.PeakClusterScore = targetCluster.MS1Score; pepIonID.PeakRT = targetCluster.PeakHeightRT[0]; pepIonID.ObservedMz = targetCluster.mz[0]; targetCluster.AssignedPepIon = pepIonID.GetKey(); } } } }
private static void setupJaasConfigEntries(String hostServerPrincipal, String hostLearnerPrincipal, String hostNamedLearnerPrincipal) { String keytabFilePath = FilenameUtils.normalize(KerberosTestUtils.getKeytabFile(), true); String jaasEntries = new String("" + "QuorumServer {\n" + " com.sun.security.auth.module.Krb5LoginModule required\n" + " useKeyTab=true\n" + " keyTab=\"" + keytabFilePath + "\"\n" + " storeKey=true\n" + " useTicketCache=false\n" + " debug=true\n" + " doNotPrompt=true\n" + " refreshKrb5Config=true\n" + " principal=\"" + KerberosTestUtils.replaceHostPattern(hostServerPrincipal) + "\";\n" + "};\n" + "QuorumLearner {\n" + " com.sun.security.auth.module.Krb5LoginModule required\n" + " useKeyTab=true\n" + " keyTab=\"" + keytabFilePath + "\"\n" + " storeKey=true\n" + " useTicketCache=false\n" + " debug=true\n" + " doNotPrompt=true\n" + " refreshKrb5Config=true\n" + " isInitiator=true\n" + " principal=\"" + KerberosTestUtils.replaceHostPattern(hostLearnerPrincipal) + "\";\n" + "};\n" + "QuorumLearnerMyHost {\n" + " com.sun.security.auth.module.Krb5LoginModule required\n" + " useKeyTab=true\n" + " keyTab=\"" + keytabFilePath + "\"\n" + " storeKey=true\n" + " useTicketCache=false\n" + " debug=true\n" + " doNotPrompt=true\n" + " refreshKrb5Config=true\n" + " isInitiator=true\n" + " principal=\"" + hostNamedLearnerPrincipal + "\";\n" + "};\n"); setupJaasConfig(jaasEntries); }
/** * Generates the file */ public void generateFile() throws IOException { // Generate data String data = generateData(); if (data == null) return; // Write data to file Logger.details("Writing " + filePath); FileWriter writer = new FileWriter(filePath, false); writer.write(data); writer.close(); Logger.ok("Created " + FilenameUtils.getName(filePath)); }
/** * Get a path Stream to iterate over all regular files matching extensions in the directory * * @param directoryPath the path to the directory * @param extensions The extensions of the files to iterate over * @return a new Stream object */ private static Stream<Path> directoryStream(@NotNull Path directoryPath, String... extensions) { try { return StreamSupport.stream(Files.newDirectoryStream(directoryPath).spliterator(), false) .filter(Files::isRegularFile) .filter(path -> Arrays.stream(extensions) .anyMatch(extension -> FilenameUtils .getExtension(path.getFileName().toString()).toLowerCase() .equals(extension.toLowerCase()))); } catch (IOException e) { throw new CouchmoveException("Unable to read directory '" + directoryPath + "'", e); } }
private String[] getComponentImpl() { ArrayList<String> ret = new ArrayList<String>(); ret.add(""); ArrayList<String> cDef = new PluginUtil().getResourcesWithExtension("cimpl", node.getContainerName()); for (String str : cDef) { String name = FilenameUtils.getBaseName(str); ret.add(name); } return ret.toArray(new String[0]); }
/** * @see HttpServlet#doPut(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // Check if it is LSP registration String lspReg = request.getHeader("Register-lsp"); if ( lspReg != null ) { handleLSPDest(Boolean.parseBoolean(lspReg), request.getReader()); return; } // Otherwise process data passed from DI if( !checkSync() ) { response.setStatus(HttpServletResponse.SC_NO_CONTENT); return; } String artifactRelPath = request.getRequestURI().substring(request.getServletPath().length() + 1); String artifactPath = this.saveDir + artifactRelPath; File destination = new File(FilenameUtils.normalize(artifactPath)); // Expected: one part containing zip try{ Part part = request.getParts().iterator().next(); WSChangeObserver changeObserver = new WSChangeObserver(ChangeType.CHANGE_UPDATED, lspDestPath); if (destination.exists() && !destination.isDirectory() && extract(part.getInputStream(), changeObserver)) { changeObserver.notifyLSP(); response.setContentType("application/json"); response.getWriter().append(String.format("{ \"updated\": \"%s\"}", artifactRelPath)); response.setStatus(HttpServletResponse.SC_OK); } else { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } catch (NoSuchElementException ePart) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); } }
public static String[] getNamesWithOutExtensionOufOfFiles(File[] files) { String[] ausgabe = new String[files.length]; int i = 0; for(File f : files) { ausgabe[i] = FilenameUtils.getBaseName(f.getName()); i++; } return ausgabe; }
public QloudsonicVoucherFinder() { super(LocalFactory.get( PreferencesFactory.get().getProperty("application.support.path")), new Filter<Local>() { @Override public boolean accept(final Local file) { return "qloudsonicvoucher".equals(FilenameUtils.getExtension(file.getName())); } @Override public Pattern toPattern() { return Pattern.compile("qloudsonicvoucher"); } }); }
/** * Constructor * * @param photoURI the URI of the photo file. */ public Photo(URI photoURI) throws FileNotFoundException { file = new File(photoURI); String filePath = file.getAbsolutePath(); Image img = buildImage(); baseName = FilenameUtils.getBaseName(filePath); format = FilenameUtils.getExtension(filePath); height = img.getHeight(); width = img.getWidth(); }