Class Zip4jUtil


  • public class Zip4jUtil
    extends Object
    • Constructor Detail

      • Zip4jUtil

        public Zip4jUtil()
    • Method Detail

      • isStringNotNullAndNotEmpty

        public static boolean isStringNotNullAndNotEmpty​(String str)
      • isWindows

        public static boolean isWindows()
      • javaToDosTime

        public static long javaToDosTime​(long time)
        Converts input time from Java to DOS format
        Parameters:
        time -
        Returns:
        time in DOS format
      • dosToJavaTme

        public static long dosToJavaTme​(int dosTime)
        Converts time in dos format to Java format
        Parameters:
        dosTime -
        Returns:
        time in java format
      • decodeFileName

        public static String decodeFileName​(byte[] data,
                                            boolean isUTF8)
        Decodes file name based on encoding. If file name is UTF 8 encoded returns an UTF8 encoded string, else return Cp850 encoded String. If appropriate charset is not supported, then returns a System default charset encoded String
        Parameters:
        data -
        isUTF8 -
        Returns:
        String
      • getCp850EncodedString

        public static String getCp850EncodedString​(byte[] data)
        Returns a string in Cp850 encoding from the input bytes. If this encoding is not supported, then String with the default encoding is returned.
        Parameters:
        data -
        Returns:
        String
      • getAbsoluteFilePath

        public static String getAbsoluteFilePath​(String filePath)
                                          throws ZipException
        Returns an absoulte path for the given file path
        Parameters:
        filePath -
        Returns:
        String
        Throws:
        ZipException
      • checkArrayListTypes

        public static boolean checkArrayListTypes​(ArrayList sourceList,
                                                  int type)
                                           throws ZipException
        Checks to see if all the elements in the arraylist match the given type
        Parameters:
        sourceList - - list to be checked
        type - - type of elements to be present in the list (ex: File, String, etc)
        Returns:
        true if all elements match the given type, if not returns false
        Throws:
        ZipException
      • detectCharSet

        public static String detectCharSet​(String str)
                                    throws ZipException
        Detects the encoding charset for the input string
        Parameters:
        str -
        Returns:
        String - charset for the String
        Throws:
        ZipException - - if input string is null. In case of any other exception this method returns default System charset
      • getEncodedStringLength

        public static int getEncodedStringLength​(String str)
                                          throws ZipException
        returns the length of the string by wrapping it in a byte buffer with the appropriate charset of the input string and returns the limit of the byte buffer
        Parameters:
        str -
        Returns:
        length of the string
        Throws:
        ZipException
      • getEncodedStringLength

        public static int getEncodedStringLength​(String str,
                                                 String charset)
                                          throws ZipException
        returns the length of the string in the input encoding
        Parameters:
        str -
        charset -
        Returns:
        int
        Throws:
        ZipException
      • isSupportedCharset

        public static boolean isSupportedCharset​(String charset)
                                          throws ZipException
        Checks if the input charset is supported
        Parameters:
        charset -
        Returns:
        boolean
        Throws:
        ZipException
      • getAllHeaderSignatures

        public static long[] getAllHeaderSignatures()