is content Type Binary - Java Network

Java examples for Network:Http

Description

is content Type Binary

Demo Code



import java.util.HashSet;
import java.util.Set;

class AttachmentUtil {
    private static final Set<String> binaryPrefixes = new HashSet<String>();
    static {/*from  w  w w  .  j av  a2 s .  co  m*/
        binaryPrefixes.add("image/");
        binaryPrefixes.add("audio/");
        binaryPrefixes.add("video/");
        binaryPrefixes.add("application/x-shockwave-flash");
    }

    public static final boolean isBinary(String contentType) {
        for (String prefix : binaryPrefixes) {
            if (contentType.startsWith(prefix)) {
                return true;
            }
        }
        return false;
    }
}

Related Tutorials