1 50 package org.apache.avalon.excalibur.monitor; 51 52 import java.io.File ; 53 import java.io.FileInputStream ; 54 import java.io.FileOutputStream ; 55 import java.io.FileReader ; 56 import java.io.FileWriter ; 57 import java.io.IOException ; 58 import java.io.InputStream ; 59 import java.io.OutputStream ; 60 import java.io.Reader ; 61 import java.io.Writer ; 62 63 73 public class FileResource 74 extends StreamResource 75 { 76 private final File m_file; 77 78 81 public FileResource( final String resource ) 82 throws Exception 83 { 84 this( new File ( resource ) ); 85 } 86 87 public FileResource( final File resource ) 88 throws Exception 89 { 90 super( resource.getCanonicalPath() ); 91 m_file = resource; 92 setPreviousModified( m_file.lastModified() ); 93 } 94 95 98 public long lastModified() 99 { 100 return m_file.lastModified(); 101 } 102 103 106 public InputStream getResourceAsStream() 107 throws IOException 108 { 109 return new FileInputStream ( m_file ); 110 } 111 112 115 public Reader getResourceAsReader() 116 throws IOException 117 { 118 return new FileReader ( m_file ); 119 } 120 121 124 public OutputStream setResourceAsStream() 125 throws IOException 126 { 127 return new ResourceOutputStream( new FileOutputStream ( m_file ), this ); 128 } 129 130 133 public Writer setResourceAsWriter() 134 throws IOException 135 { 136 return new ResourceWriter( new FileWriter ( m_file ), this ); 137 } 138 } 139 | Popular Tags |