1 25 package org.archive.util; 26 27 import java.util.regex.Matcher ; 28 import java.util.regex.Pattern ; 29 30 34 public class MimetypeUtils { 35 41 public static final String NO_TYPE_MIMETYPE = "no-type"; 42 43 46 final static Pattern TRUNCATION_REGEX = Pattern.compile("^([^\\s;,]+).*"); 47 48 49 67 public static String truncate(String contentType) { 68 if (contentType == null) { 69 contentType = NO_TYPE_MIMETYPE; 70 } else { 71 Matcher matcher = TRUNCATION_REGEX.matcher(contentType); 72 if (matcher.matches()) { 73 contentType = matcher.group(1); 74 } else { 75 contentType = NO_TYPE_MIMETYPE; 76 } 77 } 78 79 return contentType; 80 } 81 } 82 | Popular Tags |