1 package eu
.alefzero
.webdav
;
4 import java
.io
.FileInputStream
;
5 import java
.io
.IOException
;
6 import java
.io
.InputStream
;
7 import java
.io
.OutputStream
;
9 import org
.apache
.commons
.httpclient
.methods
.RequestEntity
;
12 * A RequestEntity that represents a File.
15 public class FileRequestEntity
implements RequestEntity
{
18 final String contentType
;
20 public FileRequestEntity(final File file
, final String contentType
) {
23 throw new IllegalArgumentException("File may not be null");
26 this.contentType
= contentType
;
28 public long getContentLength() {
29 return this.file
.length();
32 public String
getContentType() {
33 return this.contentType
;
36 public boolean isRepeatable() {
40 public void writeRequest(final OutputStream out
) throws IOException
{
41 byte[] tmp
= new byte[4096];
43 InputStream instream
= new FileInputStream(this.file
);
45 while ((i
= instream
.read(tmp
)) >= 0) {