Package 

Class ZipUtil


  • 
    public abstract class ZipUtil
    
                        

    Utility class for handling DOS and Java time conversions.

    • Method Summary

      Modifier and Type Method Description
      static long adjustToLong(int i) Assumes a negative integer really is a positive integer thathas wrapped around and re-creates the original value.
      static long dosToJavaTime(long dosTime) Converts DOS time to Java time (number of milliseconds sinceepoch).
      static Date fromDosTime(ZipLong zipDosTime) Convert a DOS date/time field to a Date object.
      static Array<byte> reverse(Array<byte> array) Reverses a byte[] array.
      static int signedByteToUnsignedInt(byte b) Converts a signed byte into an unsigned integer representation(e.g., -1 becomes 255).
      static ZipLong toDosTime(Date time) Convert a Date object to a DOS date/time field.
      static Array<byte> toDosTime(long t) Convert a Date object to a DOS date/time field.
      static void toDosTime(long t, Array<byte> buf, int offset) Convert a Date object to a DOS date/time field.
      static byte unsignedIntToSignedByte(int i) Converts an unsigned integer to a signed byte (e.g., 255 becomes -1).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • adjustToLong

         static long adjustToLong(int i)

        Assumes a negative integer really is a positive integer thathas wrapped around and re-creates the original value.

        Parameters:
        i - the value to treat as unsigned int.
      • dosToJavaTime

         static long dosToJavaTime(long dosTime)

        Converts DOS time to Java time (number of milliseconds sinceepoch).

        Parameters:
        dosTime - time to convert
      • fromDosTime

         static Date fromDosTime(ZipLong zipDosTime)

        Convert a DOS date/time field to a Date object.

        Parameters:
        zipDosTime - contains the stored DOS time.
      • reverse

         static Array<byte> reverse(Array<byte> array)

        Reverses a byte[] array. Reverses in-place (thus provided array ismutated), but also returns same for convenience.

        Parameters:
        array - to reverse (mutated in-place, but also returned forconvenience).
      • signedByteToUnsignedInt

         static int signedByteToUnsignedInt(byte b)

        Converts a signed byte into an unsigned integer representation(e.g., -1 becomes 255).

        Parameters:
        b - byte to convert to int
      • toDosTime

         static ZipLong toDosTime(Date time)

        Convert a Date object to a DOS date/time field.

        Parameters:
        time - the {@code Date} to convert
      • toDosTime

         static Array<byte> toDosTime(long t)

        Convert a Date object to a DOS date/time field.

        Stolen from InfoZip's {@code fileio.c}

        Parameters:
        t - number of milliseconds since the epoch
      • toDosTime

         static void toDosTime(long t, Array<byte> buf, int offset)

        Convert a Date object to a DOS date/time field.

        Stolen from InfoZip's {@code fileio.c}

        Parameters:
        t - number of milliseconds since the epoch
        buf - the output buffer
        offset - The offset within the output buffer of the first byte to be written.
      • unsignedIntToSignedByte

         static byte unsignedIntToSignedByte(int i)

        Converts an unsigned integer to a signed byte (e.g., 255 becomes -1).

        Parameters:
        i - integer to convert to byte