001 package org.hd.d.pg2k.clApp.uploader;
002
003 import java.io.File;
004 import java.io.FileInputStream;
005 import java.io.IOException;
006 import java.io.InputStream;
007 import java.io.OutputStream;
008
009 import javax.jnlp.FileContents;
010 import javax.jnlp.JNLPRandomAccessFile;
011
012 /**
013 * Created by IntelliJ IDEA.
014 * User: DHD
015 * Date: 05-Oct-2006
016 * Time: 20:19:47
017 */
018
019 /**Wrap a normal File as FileContents for non-random read-only access.
020 * Package-visible for access by GUI classes.
021 */
022 final class NormalFileContent implements FileContents
023 {
024 /**Internal form of name; never null. */
025 final File f;
026
027 /**Construct an instance from a (non-null) File. */
028 NormalFileContent(final File f)
029 {
030 if(f == null) { throw new IllegalArgumentException(); }
031 this.f = f;
032 }
033
034 public String getName() // throws IOException
035 { return(f.getPath()); }
036
037 public InputStream getInputStream() throws IOException
038 { return(new FileInputStream(f)); }
039
040 public OutputStream getOutputStream(final boolean b) // throws IOException
041 { throw new UnsupportedOperationException(); }
042
043 public long getLength() // throws IOException
044 { return(f.length()); }
045
046 public boolean canRead() // throws IOException
047 { return(f.canRead()); }
048
049 public boolean canWrite() // throws IOException
050 { return(f.canWrite()); }
051
052 public JNLPRandomAccessFile getRandomAccessFile(final String s) // throws IOException
053 { throw new UnsupportedOperationException(); }
054
055 public long getMaxLength() // throws IOException
056 { throw new UnsupportedOperationException(); }
057
058 public long setMaxLength(final long l) // throws IOException
059 { throw new UnsupportedOperationException(); }
060 }