当前位置: 首页>>代码示例>>Java>>正文


Java FilenameUtils类代码示例

本文整理汇总了Java中org.apache.commons.io.FilenameUtils的典型用法代码示例。如果您正苦于以下问题:Java FilenameUtils类的具体用法?Java FilenameUtils怎么用?Java FilenameUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FilenameUtils类属于org.apache.commons.io包,在下文中一共展示了FilenameUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FS_PeakClusterRead

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:24,代码来源:LCMSPeakBase.java

示例2: FSWrite

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:19,代码来源:LCMSID.java

示例3: testCustomizeServletContainer

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
@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();
}
 
开发者ID:oktadeveloper,项目名称:jhipster-microservices-example,代码行数:18,代码来源:WebConfigurerTest.java

示例4: DocsPage

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
/**
 * 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);
	}
}
 
开发者ID:Skyost,项目名称:SkyDocs,代码行数:30,代码来源:DocsPage.java

示例5: getOrgiUrl

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
/**
 * 缩略图文件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);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:29,代码来源:ThumbUrlUtils.java

示例6: LibraryMatchRead

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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;
    }
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:20,代码来源:TargetMatchScoring.java

示例7: exportImage

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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();
  }
}
 
开发者ID:onprom,项目名称:onprom,代码行数:24,代码来源:UMLDiagramPanel.java

示例8: createImageResource

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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);
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:19,代码来源:ImageResourceService.java

示例9: Parse

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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();
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:18,代码来源:PKLScanParser.java

示例10: contentType

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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();
	}
	
}
 
开发者ID:GastonMauroDiaz,项目名称:buenojo,代码行数:24,代码来源:BuenOjoFileUtils.java

示例11: ClusterConfigurationService

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:ClusterConfigurationService.java

示例12: loadFile

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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());
        }
    }
}
 
开发者ID:trekawek,项目名称:coffee-gb,代码行数:22,代码来源:Cartridge.java

示例13: init

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:chrisipa,项目名称:cloud-portal,代码行数:20,代码来源:MailTemplateService.java

示例14: setFileType

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jmueller95,项目名称:CORNETTO,代码行数:28,代码来源:ExportImageController.java

示例15: SaintOutput

import org.apache.commons.io.FilenameUtils; //导入依赖的package包/类
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());
                }
            }
        }
    }
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:21,代码来源:DIA_Umpire_ProtQuant.java


注:本文中的org.apache.commons.io.FilenameUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。