org.bouncycastle.bcpg.LiteralDataPacket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gwt-crypto Show documentation
Show all versions of gwt-crypto Show documentation
A GWT cryptography library ported from Legion of the Bouncy Castle.
The newest version!
package org.bouncycastle.bcpg;
import java.io.IOException;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Strings;
/**
* Generic literal data packet.
*/
public class LiteralDataPacket
extends InputStreamPacket
{
int format;
byte[] fileName;
long modDate;
LiteralDataPacket(
BCPGInputStream in)
throws IOException
{
super(in);
format = in.read();
int l = in.read();
fileName = new byte[l];
for (int i = 0; i != fileName.length; i++)
{
fileName[i] = (byte)in.read();
}
modDate = ((long)in.read() << 24) | (in.read() << 16) | (in.read() << 8) | in.read();
}
/**
* Return the format tag of the data packet.
*/
public int getFormat()
{
return format;
}
/**
* Return the modification time for the file (milliseconds at second level precision).
*/
public long getModificationTime()
{
return modDate * 1000L;
}
/**
* Return the file name associated with the data packet.
*/
public String getFileName()
{
return Strings.fromUTF8ByteArray(fileName);
}
/**
* Return the file name as an uninterpreted byte array.
*/
public byte[] getRawFileName()
{
return Arrays.clone(fileName);
}
}