Michael Thomas Flanagan's Java Scientific Library

FileOutput Class:      Writing to a File

     

Last update: 1 February 2009                                                                                                                              Main Page of Michael Thomas Flanagan's Java Scientific Library

This class contains easy to use methods for writing numbers and characters, of the following types, to a text file:
  • floating point ( double );
  • floating point ( float );
  • arbitrary precision ( BigDecimal );
  • integer ( int );
  • long integer ( long );
  • big integer ( BigInteger );
  • short integer ( short );
  • byte integer ( byte );
  • character ( char );
  • String;
  • boolean;
  • complex number ( Complex );
  • phasor ( Phasor );
  • ErrorProp;
  • ComplexErrorProp;
  • date and time;
              
  • floating point array ( double[] );
  • floating point array ( float[] );
  • arbitrary precision array ( BigDecimal[] );
  • integer array ( int[] );
  • long integer array( long[] );
  • big integer array ( BigInteger[] );
  • short integer array( short[] );
  • byte integer array( byte[] );
  • character array ( char[] );
  • String array ( String[] );
  • boolean array ( boolean[] );
  • Complex array ( Complex[] );
  • Phasor array ( Phasor[] );
  • ErrorProp array ( ErrorProp[] );
  • ComplexErrorProp array ( ComplexErrorProp[] );

with an option of also printing a following space, tab, comma, semi-colon or line return.
The space and tab methods also include an option to fix the field width of the outputted variable.
This class also incudes a static method for printing 1-dimensional and 2-dimensional arrays to a text file.
Options are provided for Methods are provided for returning the output file name actually used and checking whether a file of the given output file name already exists.

import directive: import flanagan.io.FileOutput;
Related classes:

SUMMARY OF CONSTRUCTOR AND METHODS

Constructors public FileOutput(String filename)
public FileOutput(String filename, char wan)
public FileOutput(String filename, String wan)
File name public String getFilename()
File existence check public boolean checkFileAlreadyExists()
Write to the file
with no following character
and with no line return
public final synchronized void print(double x)
public final synchronized void print(double x, int fieldWidth)
public final synchronized void print(float x)
public final synchronized void print(float x, int fieldWidth)
public final synchronized void print(BigDecimal x)
public final synchronized void print(BigDecimal x, int fieldWidth)
public final synchronized void print(int x)
public final synchronized void print(int x, int fieldWidth)
public final synchronized void print(long x)
public final synchronized void print(long x, int fieldWidth)
public final synchronized void print(BigInteger x)
public final synchronized void print(BigInteger x, int fieldWidth)
public final synchronized void print(short x)
public final synchronized void print(short x, int fieldWidth)
public final synchronized void print(byte x)
public final synchronized void print(byte x, int fieldWidth)
public final synchronized void print(char x)
public final synchronized void print(char x, int fieldWidth)
public final synchronized void print(String x)
public final synchronized void print(String x, int fieldWidth)
public final synchronized void print(boolean x)
public final synchronized void print(boolean x, int fieldWidth)
public final synchronized void print(Complex x)
public final synchronized void print(Complex x, int fieldWidth)
public final synchronized void print(Phasor x)
public final synchronized void print(Phasor x, int fieldWidth)
public final synchronized void print(ErrorProp x)
public final synchronized void print(ErrorProp x, int fieldWidth)
public final synchronized void print(ComplexErrorProp x)
public final synchronized void print(ComplexErrorProp x, int fieldWidth)
public final synchronized void print(double[] xx)
public final synchronized void print(double[] xx, int fieldWidth)
public final synchronized void print(float[] xx)
public final synchronized void print(float[] xx, int fieldWidth)
public final synchronized void print(BigDecimal[] xx)
public final synchronized void print(BigDecimal[] xx, int fieldWidth)
public final synchronized void print(int[] xx)
public final synchronized void print(int[] xx, int fieldWidth)
public final synchronized void print(long[] xx)
public final synchronized void print(BigInteger[] xx)
public final synchronized void print(BigInteger[] xx, int fieldWidth)
public final synchronized void print(long[] xx, int fieldWidth)
public final synchronized void print(short[] xx)
public final synchronized void print(short[] xx, int fieldWidth)
public final synchronized void print(byte[] xx)
public final synchronized void print(byte[] xx, int fieldWidth)
public final synchronized void print(char[] xx)
public final synchronized void print(char[] xx, int fieldWidth)
public final synchronized void print(String[] xx)
public final synchronized void print(String[] xx, int fieldWidth)
public final synchronized void print(boolean[] xx)
public final synchronized void print(boolean[] xx, int fieldWidth)
public final synchronized void print(Complex[] xx)
public final synchronized void print(Complex[] xx, int fieldWidth)
public final synchronized void print(Phasor[] xx)
public final synchronized void print(Phasor[] xx, int fieldWidth)
public final synchronized void print(ErrorProp[] xx)
public final synchronized void print(ErrorProp[] xx, int fieldWidth)
public final synchronized void print(ComplexErrorProp[] xx)
public final synchronized void print(ComplexErrorProp[] xx, int fieldWidth)
Write to the file
followed by a line return
public final synchronized void println(double x)
public final synchronized void println(float x)
public final synchronized void println(BigDecimal x)
public final synchronized void println(int x)
public final synchronized void println(long x)
public final synchronized void println(BigInteger x)
public final synchronized void println(short x)
public final synchronized void println(byte x)
public final synchronized void println(char x)
public final synchronized void println(String x)
public final synchronized void println(boolean x)
public final synchronized void println(Complex x)
public final synchronized void println(Phasor x)
public final synchronized void println(ErrorProp x)
public final synchronized void println(ComplexErrorProp x)
public final synchronized void println()
public final synchronized void println(double[] xx)
public final synchronized void println(float[] xx)
public final synchronized void println(BigDecimal[] xx)
public final synchronized void println(int[] xx)
public final synchronized void println(long[] xx)
public final synchronized void println(BigInteger[] xx)
public final synchronized void println(lshort[] xx)
public final synchronized void println(byte[] xx)
public final synchronized void println(char[] xx)
public final synchronized void println(String[] xx)
public final synchronized void println(boolean[] xx)
public final synchronized void println(Complex[] xx)
public final synchronized void println(Phasor[] xx)
public final synchronized void println(ErrorProp[] xx)
public final synchronized void println(ComplexErrorProp[] xx)
Write to the file
followed by a space
public final synchronized void printsp(double x)
public final synchronized void printsp(float x)
public final synchronized void printsp(BigDecimal x)
public final synchronized void printsp(int x)
public final synchronized void printsp(long x)
public final synchronized void printsp(BigInteger x)
public final synchronized void printsp(short x)
public final synchronized void printsp(byte x)
public final synchronized void printsp(char x)
public final synchronized void printsp(String x)
public final synchronized void printsp(boolean x)
public final synchronized void printsp(Complex x)
public final synchronized void printsp(Phasor x)
public final synchronized void printsp(ErrorProp x)
public final synchronized void printsp(ComplexErrorProp x)
public final synchronized void printsp()
public final synchronized void printsp(double[] xx)
public final synchronized void printsp(float[] xx)
public final synchronized void printsp(BigDecimal[] xx)
public final synchronized void printsp(int[] xx)
public final synchronized void printsp(long[] xx)
public final synchronized void printsp(BigInteger[] xx)
public final synchronized void printsp(short[] xx)
public final synchronized void printsp(byte[] xx)
public final synchronized void printsp(char[] xx)
public final synchronized void printsp(String[] xx)
public final synchronized void printsp(boolean[] xx)
public final synchronized void printsp(Complex[] xx)
public final synchronized void printsp(Phasor[] xx)
public final synchronized void printsp(ErrorProp[] xx)
public final synchronized void printsp(ComplexErrorProp[] xx)
Write to the file
followed by a tab
public final synchronized void printtab(double x)
public final synchronized void printtab(double x, int fieldWidth)
public final synchronized void printtab(float x)
public final synchronized void printtab(float x, int fieldWidth)
public final synchronized void printtab(BigDecimal x)
public final synchronized void printtab(BigDecimal x, int fieldWidth)
public final synchronized void printtab(BigInteger x)
public final synchronized void printtab(BigInteger x, int fieldWidth)
public final synchronized void printtab(int x)
public final synchronized void printtab(int x, int fieldWidth)
public final synchronized void printtab(long x)
public final synchronized void printtab(long x, int fieldWidth)
public final synchronized void printtab(short x)
public final synchronized void printtab(short x, int fieldWidth)
public final synchronized void printtab(byte x)
public final synchronized void printtab(byte x, int fieldWidth)
public final synchronized void printtab(char x)
public final synchronized void printtab(char x, int fieldWidth)
public final synchronized void printtab(String x)
public final synchronized void printtab(String x, int fieldWidth)
public final synchronized void printtab(boolean x)
public final synchronized void printtab(boolean x, int fieldWidth)
public final synchronized void printtab(Complex x)
public final synchronized void printtab(Complex x, int fieldWidth)
public final synchronized void printtab(Phasor x)
public final synchronized void printtab(Phasor x, int fieldWidth)
public final synchronized void printtab(ErrorProp x)
public final synchronized void printtab(ErrorProp x, int fieldWidth)
public final synchronized void printtab(ComplexErrorProp x)
public final synchronized void printtab(ComplexErrorProp x, int fieldWidth)
public final synchronized void printtab()
public final synchronized void printtab(double[] xx)
public final synchronized void printtab(double[] xx, int fieldWidth)
public final synchronized void printtab(float[] xx)
public final synchronized void printtab(float[] xx, int fieldWidth)
public final synchronized void printtab(BigDecimal[] xx)
public final synchronized void printtab(BigDecimal[] xx, int fieldWidth)
public final synchronized void printtab(int[] xx)
public final synchronized void printtab(int[] xx, int fieldWidth)
public final synchronized void printtab(long[] xx)
public final synchronized void printtab(long[] xx, int fieldWidth)
public final synchronized void printtab(BigInteger[] xx)
public final synchronized void printtab(BigInteger[] xx, int fieldWidth)
public final synchronized void printtab(short[] xx)
public final synchronized void printtab(short[] xx, int fieldWidth)
public final synchronized void printtab(byte[] xx)
public final synchronized void printtab(byte[] xx, int fieldWidth)
public final synchronized void printtab(char[] xx)
public final synchronized void printtab(char[] xx, int fieldWidth)
public final synchronized void printtab(String[] xx)
public final synchronized void printtab(String[] xx, int fieldWidth)
public final synchronized void printtab(boolean[] xx)
public final synchronized void printtab(boolean[] xx, int fieldWidth)
public final synchronized void printtab(Complex[] xx)
public final synchronized void printtab(Complex[] xx, int fieldWidth)
public final synchronized void printtab(Phasor[] xx)
public final synchronized void printtab(Phasor[] xx, int fieldWidth)
public final synchronized void printtab(ErrorProp[] xx)
public final synchronized void printtab(ErrorProp[] xx, int fieldWidth)
public final synchronized void printtab(ComplexErrorProp[] xx)
public final synchronized void printtab(ComplexErrorProp[] xx, int fieldWidth)
Write to the file
followed by a comma
public final synchronized void printcomma(double x)
public final synchronized void printcomma(float x)
public final synchronized void printcomma(BigDecimal x)
public final synchronized void printcomma(int x)
public final synchronized void printcomma(long x)
public final synchronized void printcomma(BigInteger x)
public final synchronized void printcomma(short x)
public final synchronized void printcomma(byte x)
public final synchronized void printcomma(char x)
public final synchronized void printcomma(String x)
public final synchronized void printcomma(boolean x)
public final synchronized void printcomma(Complex x)
public final synchronized void printcomma(Phasor x)
public final synchronized void printcomma(ErrorProp x)
public final synchronized void printcomma(ComplexErrorProp x)
public final synchronized void printcomma()
public final synchronized void printcomma(double[] xx)
public final synchronized void printcomma(float[] xx)
public final synchronized void printcomma(BigDecimal[] xx)
public final synchronized void printcomma(int[] xx)
public final synchronized void printcomma(long[] xx)
public final synchronized void printcomma(BigInteger[] xx)
public final synchronized void printcomma(short[] xx)
public final synchronized void printcomma(byte[] xx)
public final synchronized void printcomma(char[] xx)
public final synchronized void printcomma(String[] xx)
public final synchronized void printcomma(boolean[] xx)
public final synchronized void printcomma(Complex[] xx)
public final synchronized void printcomma(Phasor[] xx)
public final synchronized void printcomma(ErrorProp[] xx)
public final synchronized void printcomma(ComplexErrorProp[] xx)
Write to the file
followed by a semi-colon
public final synchronized void printsc(double x)
public final synchronized void printcomma(float x)
public final synchronized void printcomma(BigDecimal x)
public final synchronized void printsc(int x)
public final synchronized void printsc(long x)
public final synchronized void printcomma(BigInteger x)
public final synchronized void printsc(short x)
public final synchronized void printsc(byte x)
public final synchronized void printsc(char x)
public final synchronized void printsc(String x)
public final synchronized void printsc(boolean x)
public final synchronized void printsc(Complex x)
public final synchronized void printsc(Phasor x)
public final synchronized void printsc(ErrorProp x)
public final synchronized void printsc(ComplexErrorProp x)
public final synchronized void printsc()
public final synchronized void printsc(double[] xx)
public final synchronized void printcomma(float[] xx)
public final synchronized void printcomma(BigDecimal[] xx)
public final synchronized void printsc(int[] xx)
public final synchronized void printsc(long[] xx)
public final synchronized void printcomma(BigInteger[] xx)
public final synchronized void printsc(short[] xx)
public final synchronized void printsc(byte[] xx)
public final synchronized void printsc(char[] xx)
public final synchronized void printsc(String[] xx)
public final synchronized void printsc(boolean[] xx)
public final synchronized void printsc(Complex[] xx)
public final synchronized void printsc(Phasor[] xx)
public final synchronized void printsc(ErrorProp[] xx)
public final synchronized void printsc(ComplexErrorProp[] xx)
Date and time public final synchronized void dateAndTime()
public final synchronized void dateAndTimeln()
public final synchronized void dateAndTimesp()
public final synchronized void dateAndTimetab()
public final synchronized void dateAndTimecomma()
public final synchronized void dateAndTimesc()
Title, date and time public final synchronized void dateAndTime(String title)
public final synchronized void dateAndTimeln((String title)
public final synchronized void dateAndTimesp((String title)
public final synchronized void dateAndTimetab((String title)
public final synchronized void dateAndTimecomma((String title)
public final synchronized void dateAndTimesc((String title)
Close the file public final synchronized void close()
Write an array to a text file public static void printArrayToText(double[ ][ ] array)
public static void printArrayToText(double[ ] array)
public static void printArrayToText(float[ ][ ] array)
public static void printArrayToText(float[ ] array)
public static void printArrayToText(BigDecimal[ ][ ] array)
public static void printArrayToText(BigDecimal[ ] array)
public static void printArrayToText(int[ ][ ] array)
public static void printArrayToText(int[ ] array)
public static void printArrayToText(long[ ][ ] array)
public static void printArrayToText(BigInteger[ ][ ] array)
public static void printArrayToText(long[ ] array)
public static void printArrayToText(BigInteger[ ][ ] array)
public static void printArrayToText(BigInteger[ ] array)
public static void printArrayToText(short[ ][ ] array)
public static void printArrayToText(short[ ] array)
public static void printArrayToText(byte[ ][ ] array)
public static void printArrayToText(byte[ ] array)
public static void printArrayToText(Complex[ ][ ] array)
public static void printArrayToText(Complex[ ] array)
public static void printArrayToText(Phasor[ ][ ] array)
public static void printArrayToText(Phasor[ ] array)
public static void printArrayToText(ErrorProp[ ][ ] array)
public static void printArrayToText(ErrorProp[ ] array)
public static void printArrayToText(ComplexErrorProp[ ][ ] array)
public static void printArrayToText(ComplexErrorProp[ ] array)
public static void printArrayToText(char[ ][ ] array)
public static void printArrayToText(char[ ] array)
public static void printArrayToText(String[ ][ ] array)
public static void printArrayToText(String[ ] array)
public static void printArrayToText(boolean[ ][ ] array)
public static void printArrayToText(boolean[ ] array)
public static void printArrayToText(String fileTitle, double[ ][ ] array)
public static void printArrayToText(String fileTitle, double[ ] array)
public static void printArrayToText(String fileTitle, float[ ][ ] array)
public static void printArrayToText(String fileTitle, float[ ] array)
public static void printArrayToText(String fileTitle, BigDecimal[ ][ ] array)
public static void printArrayToText(String fileTitle, BigDecimal[ ] array)
public static void printArrayToText(String fileTitle, int[ ][ ] array)
public static void printArrayToText(String fileTitle, int[ ] array)
public static void printArrayToText(String fileTitle, long[ ][ ] array)
public static void printArrayToText(String fileTitle, long[ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ][ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ][ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ] array)
public static void printArrayToText(String fileTitle, short[ ][ ] array)
public static void printArrayToText(String fileTitle, short[ ] array)
public static void printArrayToText(String fileTitle, byte[ ][ ] array)
public static void printArrayToText(String fileTitle, byte[ ] array)
public static void printArrayToText(String fileTitle, Complex[ ][ ] array)
public static void printArrayToText(String fileTitle, Complex[ ] array)
public static void printArrayToText(String fileTitle, Phasor[ ][ ] array)
public static void printArrayToText(String fileTitle, Phasor[ ] array)
public static void printArrayToText(String fileTitle, ErrorProp[ ][ ] array)
public static void printArrayToText(String fileTitle, ErrorProp[ ] array)
public static void printArrayToText(String fileTitle, ComplexErrorProp[ ][ ] array)
public static void printArrayToText(String fileTitle, ComplexErrorProp[ ] array)
public static void printArrayToText(String fileTitle, char[ ][ ] array)
public static void printArrayToText(String fileTitle, char[ ] array)
public static void printArrayToText(String fileTitle, String[ ][ ] array)
public static void printArrayToText(String fileTitle, String[ ] array)
public static void printArrayToText(String fileTitle, boolean[ ][ ] array)
public static void printArrayToText(String fileTitle, boolean[ ] array)

CONSTRUCTORS AND METHODS

CONSTRUCTORS
public FileOutput(String filename, char wan)
public FileOutput(String filename, String wan)
Usage:                      FileOutput fout = new FileOutput(filename, wan);
Creates a new instance of FileOutput that:
if wan == 'w' or wan == "w" creates and opens a text file called by the name in filename. If a file of this name already exists it will be opened and overwritten. The filename may contain the relevant extension, e.g. filename = "xydata.txt".
if wan == 'a' or wan == "a" opens an existing file called by the name in filename and appends to this files. If a file of this name does not exist a file of this name will be created and opened. The filename may contain the relevant extension, e.g. filename = "xydata.txt".
if wan == 'n' or wan == "n" the constructor first adds a 1 to the end of the file name if there is no extension or to the filename before the extension if there is an extension, e.g. a filename, fileabc.txt, becomes fileabc1.txt. whilst a file, filexyz, becomes filexyz1. The constructor then checks if this file exists in the working directory. If it does it increments the added number, e.g. fileabc1.txt becomes fileabc2.txt or filexyz1 becomes filexyz2, and checks again. When the constructor fails to finds a file with the current incremented added number it assigns that name as the filename and opens a file of that name.
Remember you must also close the file opened once you have finished writing to it (see close() method).

public FileOutput(String filename)
Usage:                      FileOutput fout = new FileOutput(filename);
Creates a new instance of FileOutput that creates and opens a text file called by the name in filename. If a file of this name already exists it will be opened and overwritten. See above for appending data to an existing file or ensuring a file is not overwritten. The filename may contain the relevant extension, e.g. filename = "xydata.txt".
Remember you must also close the file opened once you have finished writing to it (see close() method).

Return File Name
public String getFilename()
Usage:                      fileName = fout.getFilename()
Returns the actual file name used, i.e. with suffixed numeral if the 'n' option used in the constructor.

Check if the file name already in use
public boolean checkFileAlreadyExists()
Usage:                      check = fout.checkFileAlreadyExists()
Returns true if the file name provided via the constructor argument list is already in use in the working directory. Returns false if no file of of that file name was found in the working directory. If the file name was found that file will have been overwritten if neither the 'a' or 'n' options where chosen in the constructor argument list.

WRITE TO THE FILE WITHOUT A LINE RETURN AND WITHOUT A FOLLOWING CHARACTER
No control over the field width
public final synchronized void print(double x)
public final synchronized void print(float x)
public final synchronized void print(BigDecimal x)
public final synchronized void print(int x)
public final synchronized void print(long x)
public final synchronized void print(BigInteger x)
public final synchronized void print(short x)
public final synchronized void print(byte x)
public final synchronized void print(char x)
public final synchronized void print(String x)
public final synchronized void print(boolean x)
public final synchronized void print(Complex x)
public final synchronized void print(Phasor x)
public final synchronized void print(ErrorProp x)
public final synchronized void print(ComplexErrorProp x)
Usage:                      fout.print(x);
Writes x to the file opened by fout.

public final synchronized void print(double[] xx)
public final synchronized void print(float[] xx)
public final synchronized void print(BigDecimal[] xx)
public final synchronized void print(int[] xx)
public final synchronized void print(long[] xx)
public final synchronized void print(BigInteger[] xx)
public final synchronized void print(short[] xx)
public final synchronized void print(byte[] xx)
public final synchronized void print(char[] xx)
public final synchronized void print(String[] xx)
public final synchronized void print(boolean[] xx)
public final synchronized void print(Complex[] xx)
public final synchronized void print(Phasor[] xx)
public final synchronized void print(ErrorProp[] xx)
public final synchronized void print(ComplexErrorProp[] xx)
Usage:                      fout.print(xx);
Writes the the elements of the array xx, without any separators, to the file opened by fout.

Fixed field width
public final synchronized void print(double x, int fieldWidth)
public final synchronized void print(float x, int fieldWidth)
public final synchronized void print(BigDecimal x, int fieldWidth)
public final synchronized void print(int x, int fieldWidth)
public final synchronized void print(long x, int fieldWidth)
public final synchronized void print(BigInteger x, int fieldWidth)
public final synchronized void print(short x, int fieldWidth)
public final synchronized void print(byte x, int fieldWidth)
public final synchronized void print(char x, int fieldWidth)
public final synchronized void print(String x, int fieldWidth)
public final synchronized void print(boolean x, int fieldWidth)
public final synchronized void print(Complex x, int fieldWidth)
public final synchronized void print(Phasor x, int fieldWidth)
public final synchronized void print(ErrorProp x, int fieldWidth)
public final synchronized void print(ComplexErrorProp x, int fieldWidth)
Usage:                      fout.print(x, fieldWidth);
Writes x to the file opened by fout. If the fieldWidth is greater than the length of the printed value of x, (fieldWidth - the length of x) spaces are then printed to give a total field width of fieldWidth.

public final synchronized void print(double[] xx, int fieldWidth)
public final synchronized void print(float[] xx, int fieldWidth)
public final synchronized void print(BigDecimal[] xx, int fieldWidth)
public final synchronized void print(int[] xx, int fieldWidth)
public final synchronized void print(long[] xx, int fieldWidth)
public final synchronized void print(BigInteger[] xx, int fieldWidth)
public final synchronized void print(short[] xx, int fieldWidth)
public final synchronized void print(byte[] xx, int fieldWidth)
public final synchronized void print(char[] xx, int fieldWidth)
public final synchronized void print(String[] xx, int fieldWidth)
public final synchronized void print(boolean[] xx, int fieldWidth)
public final synchronized void print(Complex[] xx, int fieldWidth)
public final synchronized void print(Phasor[] xx, int fieldWidth)
public final synchronized void print(ErrorProp[] xx, int fieldWidth)
public final synchronized void print(ComplexErrorProp[] xx, int fieldWidth)
Usage:                      fout.print(xx, fieldWidth);
Writes the elements of the array xx to the file opened by fout. If the fieldWidth is greater than the length of the printed value of each element of x[], (fieldWidth - the length of each xx[i]) spaces are then printed to give a total field width of fieldWidth.

WRITE TO THE FILE FOLLOWED BY A LINE RETURN
public final synchronized void println(double x)
public final synchronized void println(float x)
public final synchronized void println(BigDecimal x)
public final synchronized void println(int x)
public final synchronized void println(long x)
public final synchronized void println(BigInteger x)
public final synchronized void println(short x)
public final synchronized void println(byte x)
public final synchronized void println(char x)
public final synchronized void println(String x)
public final synchronized void println(boolean x)
public final synchronized void println(Complex x)
public final synchronized void println(Phasor x)
public final synchronized void println(ErrorProp x)
public final synchronized void println(ComplexErrorProp x)
Usage:                      fout.println(x);
Writes x, followed by a line return, to the file opened by fout.

public final synchronized void println(double[] xx)
public final synchronized void println(float[] xx)
public final synchronized void println(BigDecimal[] xx)
public final synchronized void println(int[] xx)
public final synchronized void println(long[] xx)
public final synchronized void println(BigInteger[] xx)
public final synchronized void println(short[] xx)
public final synchronized void println(byte[] xx)
public final synchronized void println(char[] xx)
public final synchronized void println(String[] xx)
public final synchronized void println(boolean[] xx)
public final synchronized void println(Complex[] xx)
public final synchronized void println(Phasor[] xx)
public final synchronized void println(ErrorProp[] xx)
public final synchronized void println(ComplexErrorProp[] xx)
Usage:                      fout.println(xx);
Writes each element of xx[], followed by a line return, to the file opened by fout.

public final synchronized void println()
Usage:                      fout.println();
Writes a line return to the file opened by fout.

WRITE TO THE FILE WITH A FOLLOWING SPACE
public final synchronized void printsp(double x)
public final synchronized void printsp(float x)
public final synchronized void printsp(BigDecimal x)
public final synchronized void printsp(int x)
public final synchronized void printsp(long x)
public final synchronized void printsp(BigInteger x)
public final synchronized void printsp(short x)
public final synchronized void printsp(byte x)
public final synchronized void printsp(char x)
public final synchronized void printsp(String x)
public final synchronized void printsp(boolean x)
public final synchronized void printsp(Complex x)
public final synchronized void printsp(Phasor x)
public final synchronized void printsp(ErrorProp x)
b>public final synchronized void printsp(ComplexErrorProp x)
Usage:                      fout.printsp(x);
Writes x, followed by a single space, to the file opened by fout.

public final synchronized void printsp(double[] xx)
public final synchronized void printsp(float[] xx)
public final synchronized void printsp(BigDecimal[] xx)
public final synchronized void printsp(int[] xx)
public final synchronized void printsp(long[] xx)
public final synchronized void printsp(BigInteger[] xx)
public final synchronized void printsp(short[] xx)
public final synchronized void printsp(byte[] xx)
public final synchronized void printsp(char[] xx)
public final synchronized void printsp(String[] xx)
public final synchronized void printsp(boolean[] xx)
public final synchronized void printsp(Complex[] xx)
public final synchronized void printsp(Phasor[] xx)
public final synchronized void printsp(ErrorProp[] xx)
b>public final synchronized void printsp(ComplexErrorProp[] xx)
Usage:                      fout.printsp(xx);
Writes each element of the array xx[], followed by a single space, to the file opened by fout.

public final synchronized void printsp()
Usage:                      fout.printsp();
Writes a space to the file opened by fout.

WRITE TO THE FILE WITH A FOLLOWING TAB
No control over field width
public final synchronized void printtab(double x)
public final synchronized void printtab(float x)
public final synchronized void printtab(BigDecimal x)
public final synchronized void printtab(int x)
public final synchronized void printtab(long x)
public final synchronized void printtab(BigInteger x)
public final synchronized void printtab(short x)
public final synchronized void printtab(byte x)
public final synchronized void printtab(char x)
public final synchronized void printtab(String x)
public final synchronized void printtab(boolean x)
public final synchronized void printtab(Complex x)
public final synchronized void printtab(Phasor x)
public final synchronized void printtab(ErrorProp x)
public final synchronized void printtab(ComplexErrorProp x)
Usage:                      fout.printtab(x);
Writes x, followed by a single tab, to the file opened by fout.

public final synchronized void printtab(double[] xx)
public final synchronized void printtab(float[] xx)
public final synchronized void printtab(BigDecimal[] xx)
public final synchronized void printtab(int[] xx)
public final synchronized void printtab(long[] xx)
public final synchronized void printtab(BigInteger[] xx)
public final synchronized void printtab(short[] xx)
public final synchronized void printtab(byte[] xx)
public final synchronized void printtab(char[] xx)
public final synchronized void printtab(String[] xx)
public final synchronized void printtab(boolean[] xx)
public final synchronized void printtab(Complex[] xx)
public final synchronized void printtab(Phasor[] xx)
public final synchronized void printtab(ErrorProp[] xx)
public final synchronized void printtab(ComplexErrorProp[] xx)
Usage:                      fout.printtab(xx);
Writes each element of the array, xx, followed by a single tab, to the file opened by fout.

public final synchronized void printtab()
Usage:                      fout.printtab();
Writes a tab to the file opened by fout.

Fixed field width
public final synchronized void printtab(double x, int fieldWidth)
public final synchronized void printtab(float x, int fieldWidth)
public final synchronized void printtab(BigDecimal x, int fieldWidth)
public final synchronized void printtab(int x, int fieldWidth)
public final synchronized void printtab(long x, int fieldWidth)
public final synchronized void printtab(BigInteger x, int fieldWidth)
public final synchronized void printtab(short x, int fieldWidth)
public final synchronized void printtab(byte x, int fieldWidth)
public final synchronized void printtab(char x, int fieldWidth)
public final synchronized void printtab(String x, int fieldWidth)
public final synchronized void printtab(boolean x, int fieldWidth)
public final synchronized void printtab(Complex x, int fieldWidth)
public final synchronized void printtab(Phasor x, int fieldWidth)
public final synchronized void printtab(ErrorProp x, int fieldWidth)
public final synchronized void printtab(ComplexErrorProp x, int fieldWidth)
Usage:                      fout.printtab(x, fieldWidth);
Writes x to the file opened by fout. If the fieldWidth is greater than the length of the printed value of x, (fieldWidth - the length of x) spaces are then printed to give a total field width of fieldWidth. A tab is then printed.

public final synchronized void printtab(double[] xx, int fieldWidth)
public final synchronized void printtab(float[] xx, int fieldWidth)
public final synchronized void printtab(BigDecimal[] xx, int fieldWidth)
public final synchronized void printtab(int[] xx, int fieldWidth)
public final synchronized void printtab(long[] xx, int fieldWidth)
public final synchronized void printtab(BigInteger[] xx, int fieldWidth)
public final synchronized void printtab(short[] xx, int fieldWidth)
public final synchronized void printtab(byte[] xx, int fieldWidth)
public final synchronized void printtab(char[] xx, int fieldWidth)
public final synchronized void printtab(String[] xx, int fieldWidth)
public final synchronized void printtab(boolean[] xx, int fieldWidth)
public final synchronized void printtab(Complex[] xx, int fieldWidth)
public final synchronized void printtab(Phasor[] xx, int fieldWidth)
public final synchronized void printtab(ErrorProp[] xx, int fieldWidth)
public final synchronized void printtab(ComplexErrorProp[] xx, int fieldWidth)
Usage:                      fout.printtab(xx, fieldWidth);
Writes each array elent of xx[] to the file opened by fout. If the fieldWidth is greater than the length of the printed value of the array elementxx[i], (fieldWidth - the length of xx[i]) spaces are then printed to give a total field width of fieldWidth. A tab is then printed.

WRITE TO THE FILE WITH A FOLLOWING COMMA
public final synchronized void printcomma(double x)
public final synchronized void printcomma(float x)
public final synchronized void printcomma(BigDecimal x)
public final synchronized void printcomma(int x)
public final synchronized void printcomma(long x)
public final synchronized void printcomma(BigInteger x)
public final synchronized void printcomma(short x)
public final synchronized void printcomma(byte x)
public final synchronized void printcomma(char x)
public final synchronized void printcomma(String x)
public final synchronized void printcomma(boolean x)
public final synchronized void printcomma(Complex x)
public final synchronized void printcomma(Phasor x)
public final synchronized void printcomma(ErrorProp x)
public final synchronized void printcomma(ComplexErrorProp x)
Usage:                      fout.printcomma(x);
Writes x, followed by a single comma, to the file opened by fout.

public final synchronized void printcomma()
Usage:                      fout.printcomma();
Writes a comma to the file opened by fout.

public final synchronized void printcomma(double[] xx)
public final synchronized void printcomma(float[] xx)
public final synchronized void printcomma(BigDecimal[] xx)
public final synchronized void printcomma(int[] xx)
public final synchronized void printcomma(long[] xx)
public final synchronized void printcomma(BigInteger[] xx)
public final synchronized void printcomma(short[] xx)
public final synchronized void printcomma(byte[] xx)
public final synchronized void printcomma(char[] xx)
public final synchronized void printcomma(String[] xx)
public final synchronized void printcomma(boolean[] xx)
public final synchronized void printcomma(Complex[] xx)
public final synchronized void printcomma(Phasor[] xx)
public final synchronized void printcomma(ErrorProp[] xx)
public final synchronized void printcomma(ComplexErrorProp[] xx)
Usage:                      fout.printcomma(xx);
Writes each element of the array xx[], followed by a single comma, to the file opened by fout.

WRITE TO THE FILE WITH A FOLLOWING SEMICOLON
public final synchronized void printsc(double x)
public final synchronized void printsc(float x)
public final synchronized void printsc(BigDecimal x)
public final synchronized void printsc(int x)
public final synchronized void printsc(long x)
public final synchronized void printsc(BigInteger x)
public final synchronized void printsc(short x)
public final synchronized void printsc(byte x)
public final synchronized void printsc(char x)
public final synchronized void printsc(String x)
public final synchronized void printsc(boolean x)
public final synchronized void printsc(Complex x)
public final synchronized void printsc(Phasor x)
public final synchronized void printsc(ErrorProp x)
public final synchronized void printsc(ComplexErrorProp x)
Usage:                      fout.printsc(x);
Writes x, followed by a single semi-colon, to the file opened by fout.

public final synchronized void printsc()
Usage:                      fout.printsc();
Writes a semi-colon to the file opened by fout.

public final synchronized void printsc(double[] xx)
public final synchronized void printsc(float[] xx)
public final synchronized void printsc(BigDecimal[] xx)
public final synchronized void printsc(int[] xx)
public final synchronized void printsc(long[] xx)
public final synchronized void printsc(BigInteger[] xx)
public final synchronized void printsc(short[] xx)
public final synchronized void printsc(byte[] xx)
public final synchronized void printsc(char[] xx)
public final synchronized void printsc(String[] xx)
public final synchronized void printsc(boolean[] xx)
public final synchronized void printsc(Complex[] xx)
public final synchronized void printsc(Phasor[] xx)
public final synchronized void printsc(ErrorProp[] xx)
public final synchronized void printsc(ComplexErrorProp[] xx)
Usage:                      fout.printsc(xx);
Writes each element of the array xx[], followed by a single semi-colon, to the file opened by fout.

WRITE FILE TITLE, DATE AND TIME
public final synchronized void dateAndTime(String title)
Usage:                      fout.dateAndTime(tttt);
Writes the title (in the string tttt), date and time, in the form, e.g.
if tttt = Output.txt,
This file, Output.txt, was created at 08:58:32 on 01-Aug-02
to the file opened by fout.

public final synchronized void dateAndTime()
Usage:                      fout.dateAndTime();
Writes date and time, in the form, e.g.
This file, filename, was created at 08:58:32 on 01-Aug-02
to the file opened by fout (filename is the text in the String containg the filename defined by fout).

public final synchronized void dateAndTimeln(String title)
public final synchronized void dateAndTimesp(String title)
public final synchronized void dateAndTimetab(String title)
public final synchronized void dateAndTimecomma(String title)
public final synchronized void dateAndTimesc(String title)
These are the corresponding title, date and time print methods in which a following line return, space, tab, comma or semi-colon is also printed.

public final synchronized void dateAndTimeln()
public final synchronized void dateAndTimesp()
public final synchronized void dateAndTimetab()
public final synchronized void dateAndTimecomma()
public final synchronized void dateAndTimesc()
These are the corresponding date and time print methods in which a following line return, space, tab, comma or semi-colon is also printed.

CLOSING THE FILE
public close()
Usage:                      fout.close();
A method for closing the text file opened by fout.



WRITE A 1-D OR 2-D ARRAY TO A TEXT FILE
File title provided
public static void printArrayToText(String fileTitle, double[ ][ ] array)
public static void printArrayToText(String fileTitle, double[ ] array)
public static void printArrayToText(String fileTitle, float[ ][ ] array)
public static void printArrayToText(String fileTitle, float[ ] array)
public static void printArrayToText(String fileTitle, BigDecimal[ ][ ] array)
public static void printArrayToText(String fileTitle, BigDecimal[ ] array)
public static void printArrayToText(String fileTitle, int[ ][ ] array)
public static void printArrayToText(String fileTitle, int[ ] array)
public static void printArrayToText(String fileTitle, long[ ][ ] array)
public static void printArrayToText(String fileTitle, long[ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ][ ] array)
public static void printArrayToText(String fileTitle, BigInteger[ ] array)
public static void printArrayToText(String fileTitle, short[ ][ ] array)
public static void printArrayToText(String fileTitle, short[ ] array)
public static void printArrayToText(String fileTitle, byte[ ][ ] array)
public static void printArrayToText(String fileTitle, byte[ ] array)
public static void printArrayToText(String fileTitle, Complex[ ][ ] array)
public static void printArrayToText(String fileTitle, Complex[ ] array)
public static void printArrayToText(String fileTitle, Phasor[ ][ ] array)
public static void printArrayToText(String fileTitle, Phasor[ ] array)
public static void printArrayToText(String fileTitle, ErrorProp[ ][ ] array)
public static void printArrayToText(String fileTitle, ErrorProp[ ] array)
public static void printArrayToText(String fileTitle, ComplexErrorProp[ ][ ] array)
public static void printArrayToText(String fileTitle, ComplexErrorProp[ ] array)
public static void printArrayToText(String fileTitle, char[ ][ ] array)
public static void printArrayToText(String fileTitle, char[ ] array)
public static void printArrayToText(String fileTitle, String[ ][ ] array)
public static void printArrayToText(String fileTitle, String[ ] array)
public static void printArrayToText(String fileTitle, boolean[ ][ ] array)
public static void printArrayToText(String fileTitle, boolean[ ] array)
Usage:                      FileOutput.printArrayToText(fileTitle, array);
A static method that writes an array to a text file called fileTitle String followed by N, where N is an integer indicating the last output. The array may be one dimensional or two dimensional and its elements may be of type double, float, BigDecimal, int, long, BigInteger, Complex, Phasor, ErrorProp, ComplexErrorProp, char, String or boolean. The text file is date and time stamped.

No file title provided
public static void printArrayToText(double[ ][ ] array)
public static void printArrayToText(double[ ] array)
public static void printArrayToText(float[ ][ ] array)
public static void printArrayToText(float[ ] array)
public static void printArrayToText(BigDecimal[ ][ ] array)
public static void printArrayToText(BigDecimal[ ] array)
public static void printArrayToText(int[ ][ ] array)
public static void printArrayToText(int[ ] array)
public static void printArrayToText(long[ ][ ] array)
public static void printArrayToText(long[ ] array)
public static void printArrayToText(BigInteger[ ][ ] array)
public static void printArrayToText(BigInteger[ ] array)
public static void printArrayToText(short[ ][ ] array)
public static void printArrayToText(short[ ] array)
public static void printArrayToText(byte[ ][ ] array)
public static void printArrayToText(byte[ ] array)
public static void printArrayToText(Complex[ ][ ] array)
public static void printArrayToText(Complex[ ] array)
public static void printArrayToText(Phasor[ ][ ] array)
public static void printArrayToText(Phasor[ ] array)
public static void printArrayToText(ErrorProp[ ][ ] array)
public static void printArrayToText(ErrorProp[ ] array)
public static void printArrayToText(ComplexErrorProp[ ][ ] array)
public static void printArrayToText(ComplexErrorProp[ ] array)
public static void printArrayToText(char[ ][ ] array)
public static void printArrayToText(char[ ] array)
public static void printArrayToText(String[ ][ ] array)
public static void printArrayToText(String[ ] array)
public static void printArrayToText(boolean[ ][ ] array)
public static void printArrayToText(boolean[ ] array)
Usage:                      FileOutput.printArrayToText(array);
A static method that writes an array to a text file called ArrayToTextN, where N is an integer indicating the last output. The array may be one dimensional or two dimensional and its elements may be of type double, float, BigDecimal, int, long, BigInteger, Complex, Phasor, ErrorProp, ComplexErrorProp, char, String or boolean. The text file is date and time stamped.



OTHER CLASSES USED BY THIS CLASS

This class uses the following classes in this library:


This page was prepared by Dr Michael Thomas Flanagan