View Javadoc
1   package org.codehaus.plexus.archiver.zip;
2   
3   import java.io.File;
4   import java.io.IOException;
5   import java.io.InputStream;
6   import java.net.URL;
7   import javax.annotation.Nonnull;
8   import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource;
9   
10  public class AnonymousResource extends AbstractPlexusIoResource
11  {
12  
13      private final File file;
14  
15      public AnonymousResource( File file )
16      {
17          this( file, getName( file ) );
18      }
19  
20      public AnonymousResource( File file, String name )
21      {
22          super( name, file.lastModified(), file.length(), file.isFile(), file.isDirectory(), file.exists() );
23          this.file = file;
24      }
25  
26      @Nonnull
27      @Override
28      public InputStream getContents()
29          throws IOException
30      {
31          throw new UnsupportedOperationException( "not supp" );
32          // Does this really have an input stream ?
33          //return new FileInputStream( file );
34      }
35  
36      @Override
37      public URL getURL()
38          throws IOException
39      {
40          return file.toURI().toURL();
41      }
42  
43      private static String getName( File file )
44      {
45          return file.getPath().replace( '\\', '/' );
46      }
47  
48  }