Java Text File Write writeString(File file, String string)

Here you can find the source of writeString(File file, String string)

Description

write String

License

Apache License

Declaration

public static void writeString(File file, String string) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    public static void writeString(File file, String string) {
        FileOutputStream fos = null;
        try {/*from ww  w .  j a  va  2  s. c  o  m*/
            fos = new FileOutputStream(file, false);
            fos.write(string.getBytes("UTF-8"));
        } catch (Exception e) {
        } finally {
            close(null, fos);
        }
    }

    private static void close(InputStream is, OutputStream os) {
        if (is != null)
            try {
                is.close();
            } catch (IOException e) {
            }
        if (os != null)
            try {
                os.close();
            } catch (IOException e) {
            }
    }
}

Related

  1. writeString(File file, String data)
  2. writeString(File file, String s, int bufferSize, String encoding)
  3. writeString(File file, String str)
  4. writeString(File file, String str, String encoding)
  5. writeString(File file, String string)
  6. writeString(File outputFile, String text)
  7. writeString(FileWriter fw, String s)
  8. writeString(final ObjectOutput objectOut, final String str)
  9. writeString(final ObjectOutput out, final String s)