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


Java MimetypesFileTypeMap.addMimeTypes方法代码示例

本文整理汇总了Java中javax.activation.MimetypesFileTypeMap.addMimeTypes方法的典型用法代码示例。如果您正苦于以下问题:Java MimetypesFileTypeMap.addMimeTypes方法的具体用法?Java MimetypesFileTypeMap.addMimeTypes怎么用?Java MimetypesFileTypeMap.addMimeTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.activation.MimetypesFileTypeMap的用法示例。


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

示例1: registerMediaTypes

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
private void registerMediaTypes() {
  // Common MIME types used for uploading attachments.
  mediaTypes = new MimetypesFileTypeMap();
  mediaTypes.addMimeTypes("application/msword doc");
  mediaTypes.addMimeTypes("application/vnd.ms-excel xls");
  mediaTypes.addMimeTypes("application/pdf pdf");
  mediaTypes.addMimeTypes("text/richtext rtx");
  mediaTypes.addMimeTypes("text/csv csv");
  mediaTypes.addMimeTypes("text/tab-separated-values tsv tab");
  mediaTypes.addMimeTypes("application/x-vnd.oasis.opendocument.spreadsheet ods");
  mediaTypes.addMimeTypes("application/vnd.oasis.opendocument.text odt");
  mediaTypes.addMimeTypes("application/vnd.ms-powerpoint ppt pps pot");
  mediaTypes.addMimeTypes("application/vnd.openxmlformats-officedocument."
      + "wordprocessingml.document docx");
  mediaTypes.addMimeTypes("application/vnd.openxmlformats-officedocument."
      + "spreadsheetml.sheet xlsx");
  mediaTypes.addMimeTypes("audio/mpeg mp3 mpeg3");
  mediaTypes.addMimeTypes("image/png png");
  mediaTypes.addMimeTypes("application/zip zip");
  mediaTypes.addMimeTypes("application/x-tar tar");
  mediaTypes.addMimeTypes("video/quicktime qt mov moov");
  mediaTypes.addMimeTypes("video/mpeg mpeg mpg mpe mpv vbs mpegv");
  mediaTypes.addMimeTypes("video/msvideo avi");
}
 
开发者ID:google,项目名称:gdata-java-client,代码行数:25,代码来源:SitesHelper.java

示例2: getResult

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
/**
 * @return A MimeMultipart object containing the zipped result files
 */
public MimeMultipart getResult() {

    File file = new File(JPLAG_RESULTS_DIRECTORY + File.separator
            + submissionID + getUsername() + ".zip");

    MimeMultipart mmp = new MimeMultipart();

    FileDataSource fds1 = new FileDataSource(file);
    MimetypesFileTypeMap mftp = new MimetypesFileTypeMap();
    mftp.addMimeTypes("multipart/zip zip ZIP");
    fds1.setFileTypeMap(mftp);

    MimeBodyPart mbp = new MimeBodyPart();

    try {
        mbp.setDataHandler(new DataHandler(fds1));
        mbp.setFileName(file.getName());

        mmp.addBodyPart(mbp);
    } catch (MessagingException me) {
        me.printStackTrace();
    }
    return mmp;
}
 
开发者ID:jplag,项目名称:jplag,代码行数:28,代码来源:AccessStructure.java

示例3: isImage

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
public static boolean isImage(File image) {
    MimetypesFileTypeMap mimetypesFileTypeMap = new MimetypesFileTypeMap();
    mimetypesFileTypeMap.addMimeTypes("image png tif jpg jpeg bmp");

    String mimeType = mimetypesFileTypeMap.getContentType(image);
    String type = mimeType.split("/")[0];
    return type.equals("image");
}
 
开发者ID:kaladivo,项目名称:android-icon-generator,代码行数:9,代码来源:FileUtils.java

示例4: initFileTypeMap

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
private static void initFileTypeMap() {
    fileTypeMap = new MimetypesFileTypeMap();

    // Additional MIME types
    fileTypeMap.addMimeTypes("application/atom+xml atom");
    fileTypeMap.addMimeTypes("application/msword doc dot");
    fileTypeMap.addMimeTypes("application/mspowerpoint ppt pot");
    fileTypeMap.addMimeTypes("application/msexcel xls");
    fileTypeMap.addMimeTypes("application/pdf pdf");
    fileTypeMap.addMimeTypes("application/rdf+xml rdf rss");
    fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat docx docm dotx dotm");
    fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat xlsx xlsm");
    fileTypeMap.addMimeTypes("application/x-vnd.openxmlformat pptx pptm potx");
    fileTypeMap.addMimeTypes("application/x-javascript js");
    fileTypeMap.addMimeTypes("application/x-rar-compressed rar");
    fileTypeMap.addMimeTypes("application/x-textedit bat cmd");
    fileTypeMap.addMimeTypes("application/zip zip");
    fileTypeMap.addMimeTypes("audio/mpeg mp3");
    fileTypeMap.addMimeTypes("image/bmp bmp");
    fileTypeMap.addMimeTypes("image/gif gif");
    fileTypeMap.addMimeTypes("image/jpeg jpg jpeg jpe");
    fileTypeMap.addMimeTypes("image/png png");
    fileTypeMap.addMimeTypes("text/css css");
    fileTypeMap.addMimeTypes("text/csv csv");
    fileTypeMap.addMimeTypes("text/html htm html");
    fileTypeMap.addMimeTypes("text/xml xml");
    fileTypeMap.addMimeTypes("video/quicktime qt mov moov");
    fileTypeMap.addMimeTypes("video/mpeg mpeg mpg mpe mpv vbs mpegv");
    fileTypeMap.addMimeTypes("video/msvideo avi");
    fileTypeMap.addMimeTypes("video/mp4 mp4");
    fileTypeMap.addMimeTypes("video/ogg ogg");

    FileTypeMap.setDefaultFileTypeMap(fileTypeMap);
}
 
开发者ID:polarsys,项目名称:eplmp,代码行数:35,代码来源:BinaryResourceDownloadMeta.java

示例5: getMimeTypeWithCustomConfiguredType

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
/**
 * Introduced to dispel claims in a thread on Stack Overflow:
 * <a href="http://stackoverflow.com/questions/22986109/testing-spring-managed-servlet">Testing Spring managed servlet</a>
 */
@Test
public void getMimeTypeWithCustomConfiguredType() {
	FileTypeMap defaultFileTypeMap = FileTypeMap.getDefaultFileTypeMap();
	assertThat(defaultFileTypeMap, instanceOf(MimetypesFileTypeMap.class));
	MimetypesFileTypeMap mimetypesFileTypeMap = (MimetypesFileTypeMap) defaultFileTypeMap;
	mimetypesFileTypeMap.addMimeTypes("text/enigma    enigma");
	assertEquals("text/enigma", sc.getMimeType("filename.enigma"));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:MockServletContextTests.java

示例6: setContentTypeHeader

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
/**
 * This will set the content types of files. If you want to support any
 * files add the content type and corresponding file extension here.
 *
 * @param response
 * @param file
 */
private static void setContentTypeHeader(HttpResponse response, File file) {
    MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap();
    mimeTypesMap.addMimeTypes("image png tif jpg jpeg bmp");
    mimeTypesMap.addMimeTypes("text/plain txt");
    mimeTypesMap.addMimeTypes("application/pdf pdf");

    String mimeType = mimeTypesMap.getContentType(file);

    response.headers().set(CONTENT_TYPE, mimeType);
}
 
开发者ID:classtag,项目名称:scratch_zookeeper_netty,代码行数:18,代码来源:HttpStaticFileServerHandler.java

示例7: init

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
/**
 * 初始化.
 */
@Override
public void init() throws ServletException {
	//保存applicationContext以备后用,纯演示.
	applicationContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());

	//初始化mimeTypes, 默认缺少css的定义,添加之.
	mimetypesFileTypeMap = new MimetypesFileTypeMap();
	mimetypesFileTypeMap.addMimeTypes("text/css css");
}
 
开发者ID:Michaelleolee,项目名称:appengine,代码行数:13,代码来源:StaticContentServlet.java

示例8: init

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
public void init(FilterConfig filterConfig) throws ServletException {
    this.filterConfig = filterConfig;
    // 初始化mimeTypes, 默认缺少css的定义,添加之.
    mimetypesFileTypeMap = new MimetypesFileTypeMap();
    mimetypesFileTypeMap.addMimeTypes("text/css css");
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:7,代码来源:StaticContentFilter.java

示例9: checkPnmlFile

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
/**
 * Checks a PNML document. Stats are computed after having loaded the PNML
 * document. 
 * <p>This methods initialises a PNML doc workspace in the PFW ModelRepository, if
 * there is none currently open. So if you want it to destroy the current workspace before calling this method
 * again, use the {@link #dispose()} method first.
 * </p>
 * 
 * @throws InvalidFileException
 *             document has formating errors.
 * @throws InvalidFileTypeException
 *             document is not of the correct type.
 * @throws ValidationException
 *             document is not valid
 * @throws InternalException
 *             some internal problem
 * @param filePath
 *            the path of the PNML document.
 * @return the validation message.
 */
public final String checkPnmlFile(String filePath) throws InvalidFileException, InvalidFileTypeException,
		ValidationException, InternalException {
	initWorkspace();
	resetMessage();
	message = new StringBuilder(BUFFER_SIZE);
	try {

		final File pFile = new File(filePath);
		if (!pFile.exists()) {
			throw new InvalidFileException("File " + pFile.getName() + " does not exist.", new Throwable("File "
					+ pFile.getName() + " does not exist."));
		}
		// check if regular file or directory
		if (!pFile.isFile()) {
			throw new InvalidFileTypeException(pFile.getName() + " is not a regular file.", new Throwable(
					pFile.getName() + " is not a regular file."));
		}
		if (!pFile.canRead()) {
			throw new InvalidFileException("Cannot read file " + pFile.getName(), new Throwable("Cannot read file "
					+ pFile.getName()));
		}
		final MimetypesFileTypeMap ftm = new MimetypesFileTypeMap();
		ftm.addMimeTypes("text/xml xml pnml XML PNML");
		final String contentType = ftm.getContentType(pFile);
		if (!contentType.contains("text/xml")) {
			throw new InvalidFileTypeException(pFile.getName() + " is not an XML file: " + contentType,
					new Throwable(pFile.getName() + " is not an XML file: " + contentType));
		}
		importPnmlFile(pFile);
		setUpStats();
		if (ptDocStat != null) {
			writeConformanceMessage();
			writeStatsMessage();
		} else {
			writeUnknowPNMessage();
		}
	} catch (NullPointerException npe) {
		npe.printStackTrace();
		throw new InternalException("Null pointer exception", new Throwable(
				"Something went wrong. Please, re-submit."));
	} catch (SecurityException se) {
		throw new InternalException(se.getMessage(), new Throwable(
				"Access right problem while accessing the file system. Please, re-submit."));
	}
	return message.toString();
}
 
开发者ID:lip6,项目名称:pnmlframework,代码行数:67,代码来源:CheckPnmlFileImpl.java

示例10: tryMimetypesFileTypeMap

import javax.activation.MimetypesFileTypeMap; //导入方法依赖的package包/类
private String tryMimetypesFileTypeMap(File aFile) {
    final MimetypesFileTypeMap mtftp = new MimetypesFileTypeMap();
    mtftp.addMimeTypes("image " + IMAGE_FORMATS);
    mtftp.addMimeTypes("application/zip zip");
    return mtftp.getContentType(aFile);
}
 
开发者ID:magarena,项目名称:magarena,代码行数:7,代码来源:FileDropTargetListener.java


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