View Javadoc

    1   /*
    2    * Copyright (c) 2001-2003 The XDoclet team
    3    * All rights reserved.
    4    */
    5   package xjavadoc.filesystem;
    6
    7   import java.io.File;
    8   import java.io.FileInputStream;
    9   import java.io.InputStreamReader;
    10  import java.io.Reader;
    11  import java.io.IOException;
    12  import java.io.UnsupportedEncodingException;
    13  import java.io.Writer;
    14  import java.io.FileReader;
    15  import java.io.FileWriter;
    16  import java.io.OutputStream;
    17  import java.io.FileOutputStream;
    18  import java.io.FileNotFoundException;
    19
    20  /***
    21   * @created   September 25, 2002
    22   */
    23  public class XJavadocFile implements AbstractFile
    24  {
    25  	private File       file;
    26
    27  	public XJavadocFile( File file )
    28  	{
    29  		this.file = file;
    30  	}
    31
    32  	public Reader getReader() throws IOException
    33  	{
    34  		return new FileReader( file );
    35  	}
    36
    37  	public Reader getReader(String enc) throws UnsupportedEncodingException, FileNotFoundException
    38  	{
    39  		if (enc!=null)
    40  		{
    41  			return new InputStreamReader(new FileInputStream(file),enc);
    42  		}
    43  		else
    44  		{
    45  			return new InputStreamReader(new FileInputStream(file));
    46  		}
    47
    48  	}
    49
    50  	public Writer getWriter() throws IOException
    51  	{
    52  		return new FileWriter( file );
    53  	}
    54
    55  	public boolean isWriteable()
    56  	{
    57  		return file.canWrite();
    58  	}
    59
    60  	public OutputStream getOutputStream() throws FileNotFoundException
    61  	{
    62  		return new FileOutputStream( file );
    63  	}
    64
    65  	public String getPath()
    66  	{
    67  		return file.getAbsolutePath();
    68  	}
    69
    70  	public long lastModified()
    71  	{
    72  		return file.lastModified();
    73  	}
    74
    75  	public String toString()
    76  	{
    77  		return "File " + file.getAbsolutePath();
    78  	}
    79  }