001package org.jszip.pseudo.io; 002 003import java.io.File; 004import java.io.FileOutputStream; 005import java.io.FileWriter; 006import java.io.IOException; 007import java.io.OutputStreamWriter; 008 009/** 010 * @author stephenc 011 * @since 30/01/2013 00:42 012 */ 013public class PseudoFileWriter extends OutputStreamWriter { 014 /** 015 * Constructs a FileWriter object given a file name. 016 * 017 * @param fileName String The system-dependent filename. 018 * @throws java.io.IOException if the named file exists but is a directory rather 019 * than a regular file, does not exist but cannot be 020 * created, or cannot be opened for any other reason 021 */ 022 public PseudoFileWriter(String fileName) throws IOException { 023 super(new PseudoFileOutputStream(fileName)); 024 } 025 026 /** 027 * Constructs a FileWriter object given a file name with a boolean 028 * indicating whether or not to append the data written. 029 * 030 * @param fileName String The system-dependent filename. 031 * @param append boolean if <code>true</code>, then data will be written 032 * to the end of the file rather than the beginning. 033 * @throws IOException if the named file exists but is a directory rather 034 * than a regular file, does not exist but cannot be 035 * created, or cannot be opened for any other reason 036 */ 037 public PseudoFileWriter(String fileName, boolean append) throws IOException { 038 super(new PseudoFileOutputStream(fileName, append)); 039 } 040 041 /** 042 * Constructs a FileWriter object given a File object. 043 * 044 * @param file a File object to write to. 045 * @throws IOException if the file exists but is a directory rather than 046 * a regular file, does not exist but cannot be created, 047 * or cannot be opened for any other reason 048 */ 049 public PseudoFileWriter(PseudoFile file) throws IOException { 050 super(new PseudoFileOutputStream(file)); 051 } 052 053 /** 054 * Constructs a FileWriter object given a File object. If the second 055 * argument is <code>true</code>, then bytes will be written to the end 056 * of the file rather than the beginning. 057 * 058 * @param file a File object to write to 059 * @param append if <code>true</code>, then bytes will be written 060 * to the end of the file rather than the beginning 061 * @throws IOException if the file exists but is a directory rather than 062 * a regular file, does not exist but cannot be created, 063 * or cannot be opened for any other reason 064 * @since 1.4 065 */ 066 public PseudoFileWriter(PseudoFile file, boolean append) throws IOException { 067 super(new PseudoFileOutputStream(file, append)); 068 } 069 070}