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

model.util.FileInputOutput Maven / Gradle / Ivy

There is a newer version: 2.3.3
Show newest version
package model.util;

import java.io.*;

/**
 * @author Quinn Liu ([email protected])
 * @version June 26, 2013
 */
public class FileInputOutput {

    public static void saveObjectToTextFile(String string,
                                            String textFileName) throws IOException {
        BufferedWriter bw = null;
        try {
            bw = new BufferedWriter(new FileWriter(new File(textFileName)));
            bw.write(string);
        } finally {
            try {
                bw.close();
            } catch (Exception e) {

            }
        }
    }

    public static String openObjectInTextFile(String textFileName)
            throws IOException {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader(new File(textFileName)));
            return br.readLine();
        } finally {
            try {
                br.close();
            } catch (Exception e) {

            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy