1 26 27 package net.sourceforge.groboutils.util.io.v1; 28 29 import java.io.InputStream ; 30 import java.io.IOException ; 31 32 33 34 44 public class ResourceInputStreamGenerator implements IInputStreamGenerator 45 { 46 private String root; 47 private String orig; 48 49 53 public ResourceInputStreamGenerator( String originalName ) 54 { 55 this.orig = originalName; 56 int pos = originalName.lastIndexOf('.'); 57 if (pos >= 0) 58 { 59 originalName = originalName.substring( 0, pos+1 ); 60 } 61 else 62 { 63 originalName = ""; 64 } 65 this.root = originalName; 66 } 67 68 69 public String getFullName( String relativeName ) 70 { 71 if (!this.orig.equals( relativeName )) 72 { 73 relativeName = this.root + relativeName; 74 } 75 return relativeName; 76 } 77 78 79 public InputStream createInputStream( String relativeName ) 80 throws IOException 81 { 82 return ClassLoader.getSystemResourceAsStream( 83 getFullName( relativeName ) ); 84 } 85 } 86 | Popular Tags |