Java Text File Append appendStringToFile(String fileName, String data)

Here you can find the source of appendStringToFile(String fileName, String data)

Description

append String To File

License

GNU General Public License

Declaration

public static boolean appendStringToFile(String fileName, String data) 

Method Source Code

//package com.java2s;
/** This class is a PanelLeft factory, creating all panels based on the
 * contents of the panels.xml file.// ww w .  ja  va2  s.  c  o  m
 *
 * Last Updated:  May 25, 2011
 *
 * by Rick C. Hodgin
 * Cossatot Analytics Laboratories, LLC. (Cana Labs)
 *
 * (c) Copyright Cana Labs.
 * Free software licensed under the GNU GPL2.
 *
 * @author Rick C. Hodgin
 * @version 1.0.0
 *
 * Change history:
 *   2011-05-25 - 1.0.0 - Initial release
 *
 */

import java.io.DataOutputStream;
import java.io.File;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Main {
    public static boolean appendStringToFile(String fileName, String data) {
        int i;

        try {
            File f;
            FileOutputStream fo;

            f = new File(fileName);
            fo = new FileOutputStream(f, true);
            DataOutputStream dos = new DataOutputStream(fo);

            // Write each item in turn
            dos.writeBytes(data);

            dos.close();
            return (true);

        } catch (FileNotFoundException ex) {
        } catch (IOException ex) {
        }
        return (false);
    }
}

Related

  1. appendStringToFile(File file, String string)
  2. appendStringToFile(File file, String string)
  3. appendStringToFile(File file, String string)
  4. appendStringToFile(final String path, final String output)
  5. appendStringToFile(String file, String contents)
  6. appendStringToFile(String str, String oFileName)
  7. appendStringToFile(String string, String filename)
  8. FileAppend(String fileNameWithPath, String content)
  9. fileAppend(String target, String source)