john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

FileUtilities

package net.kittyandbear.xml;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public class FileUtilities
{

    FileOutputStream getFileOutputStream( String pathAndFilename ) throws IllegalArgumentException
    {
        if( pathAndFilename == null )
        {           throw new IllegalArgumentException( "Path and Filename cannot be null" );
        }

        FileOutputStream fo = null;
        try{
            fo = new FileOutputStream( pathAndFilename );
        }catch( FileNotFoundException fnfe )
        {       System.err.println( "Unable to open file for writing: " + pathAndFilename );
                throw new IllegalArgumentException( "Unable to open file for writing: " );
        }catch( Exception e )
        {       e.printStackTrace();
        }

        return fo;
    }

    FileInputStream getFileInputStream( String pathAndFilename ) throws IllegalArgumentException
    {
        if( pathAndFilename == null )
        {           throw new IllegalArgumentException( "Path and Filename cannot be null" );
        }

        FileInputStream fo = null;
        try{
            fo = new FileInputStream( pathAndFilename );
        }catch( FileNotFoundException fnfe )
        {       System.err.println( "Unable to open file for reading: " + pathAndFilename );
                throw new IllegalArgumentException( "Unable to open file for reading: " );
        }catch( Exception e )
        {       e.printStackTrace();
        }

        return fo;
    }

}

  • « XMLWriter
  • XMLReader INCOMPLETE »

Published

Mar 19, 2012

Category

java-classes

~115 words

Tags

  • classes 92
  • fileutilities 1
  • java 252