Examples of MagicMatch


Examples of net.sf.jmimemagic.MagicMatch

     * @param byte[] dataFile
     * @return
     */
    public static String getMimeType(byte[] dataFile) {
        String mimeType = null;
        MagicMatch magic;
        try {
            magic = Magic.getMagicMatch(dataFile);
            mimeType = magic.getMimeType();
        } catch (MagicParseException e) {
            throw new MimeTypeException(
                    "Ocorreu um erro ao tentar obter o tipo do arquivo", e);
        } catch (MagicMatchNotFoundException e) {
            throw new MimeTypeException(
View Full Code Here

Examples of net.sf.jmimemagic.MagicMatch

      //if(!StringUtil.isEmpty(mt,true)) return mt;
     
      PrintStream out = System.out;
        try {
          System.setOut(new PrintStream(DevNullOutputStream.DEV_NULL_OUTPUT_STREAM));
            MagicMatch match = Magic.getMagicMatch(barr);
            return match.getMimeType();
        }
        catch (Throwable t) {
      return defaultValue;
        }
        finally {
View Full Code Here

Examples of net.sf.jmimemagic.MagicMatch

      try {
        if (source instanceof byte[]) {

          byte[] data      = (byte[]) source;
          MagicMatch match = Magic.getMagicMatch(data);
          String mimeType  = match.getMimeType();

          if (keyAndClass != null) {

            img = (Image) ImageHelper.createFile(securityContext, data, mimeType, keyAndClass.getCls());
View Full Code Here

Examples of net.sf.jmimemagic.MagicMatch

      return mimeType;
    }

    // fallback: jmimemagic
    try {
      final MagicMatch match = Magic.getMagicMatch(file, false, true);
      if (match != null) {

        return match.getMimeType();
      }

    } catch (MagicParseException | MagicMatchNotFoundException | MagicException ignore) {
      // mex.printStackTrace();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.