All Downloads are FREE. Search and download functionalities are using the official Maven repository.

JSci.io.TextReader Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.io;

import java.io.*;
import java.util.Vector;

import JSci.maths.matrices.AbstractDoubleMatrix;

/**
* TextReader: reads data text files/streams.
* This class uses buffered I/O.
* @version 2.0
* @author Mark Hale
*/
public final class TextReader extends BufferedReader {
        /**
        * Reads text data from a reader.
        */
        public TextReader(Reader reader) {
                super(reader);
        }
        /**
        * Reads a text file with the specified system dependent file name.
        * @param name the system dependent file name.
        * @exception FileNotFoundException If the file is not found.
        */
        public TextReader(String name) throws FileNotFoundException {
                this(new FileReader(name));
        }
        /**
        * Reads a text file with the specified File object.
        * @param file the file to be opened for reading.
        * @exception FileNotFoundException If the file is not found.
        */
        public TextReader(File file) throws FileNotFoundException {
                this(new FileReader(file));
        }
        /**
        * Reads data to an array.
        * Autodetects the delimiter.
        * @exception IOException If an I/O error occurs.
        */
        public double[][] readArray() throws IOException {
                final Vector rows=new Vector();
                String line = readLine();
                while(line != null && line.length() > 0) {
                    line = line.trim();
                    // detect delimiter
                    int delimiter = -1;
                    int i;
                    for(i=0; i 0; i++) {
                    line = line.trim();
                    // detect delimiter
                    int delimiter = -1;
                    int k;
                    for(k=0; k 0; i++) {
                    line = line.trim();
                    // detect delimiter
                    int delimiter = -1;
                    int k;
                    for(k=0; k




© 2015 - 2024 Weber Informatics LLC | Privacy Policy