Java FileOutputStream Write saveStringIntoFile(String filePath, String contents)

Here you can find the source of saveStringIntoFile(String filePath, String contents)

Description

save String Into File

License

Open Source License

Declaration

public static boolean saveStringIntoFile(String filePath, String contents) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static boolean saveStringIntoFile(String filePath, String contents) {
        File file = new File(filePath);

        try {/*from w  w  w  .  j  a v  a 2  s.  co m*/
            new FileOutputStream(file).write(contents.getBytes());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return false;
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}

Related

  1. saveStream(InputStream is, File output)
  2. saveStream(InputStream stream, File targetFile)
  3. saveStreamToFile(InputStream in, File outFile)
  4. saveStreamToFile(InputStream is, File destFile)
  5. saveStringIntoFile(File file, String contents)
  6. saveStringsList(String file, Collection c)
  7. saveStringToFile(File file, String content, String charset)
  8. saveTemp(final byte[] data, final String suffix)
  9. saveTempFile(String xmlSource, String fileName)