Back to project page webimageloader.
The source code is released under:
Apache License
If you think the Android project webimageloader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.webimageloader.loader; //from w ww. j a va 2s .co m import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Metadata { public static final long NEVER_EXPIRES = -1; private String contentType; private long lastModified; private long expires; private String etag; public static Metadata from(InputStream is) throws IOException { DataInputStream stream = new DataInputStream(is); String contentType = stream.readUTF(); long lastModified = stream.readLong(); long expires = stream.readLong(); String etag = stream.readUTF(); return new Metadata(contentType, lastModified, expires, etag); } public void writeTo(OutputStream os) throws IOException { DataOutputStream stream = new DataOutputStream(os); stream.writeUTF(contentType); stream.writeLong(lastModified); stream.writeLong(expires); stream.writeUTF(etag); } public Metadata(String contentType, long lastModified, long expires, String etag) { // Don't allow strings to be null, this causes errors // when we write it to the outputstream later on if (contentType == null) { contentType = ""; } if (etag == null) { etag = ""; } this.contentType = contentType; this.lastModified = lastModified; this.expires = expires; this.etag = etag; } public String getContentType() { return contentType; } public long getLastModified() { return lastModified; } public long getExpires() { return expires; } public String getEtag() { return etag; } }