Java FileOutputStream Write saveFile(String file, String text)

Here you can find the source of saveFile(String file, String text)

Description

save File

License

Open Source License

Declaration

public static final void saveFile(String file, String text) 

Method Source Code

//package com.java2s;

import java.io.File;
import java.io.FileOutputStream;

public class Main {
    public static final void saveFile(String file, String text) {
        try {/*from   w  ww .j a v a 2 s  . c  o m*/
            File f = new File(file);
            if (!f.exists())
                f.createNewFile();
            FileOutputStream fout = new FileOutputStream(f);
            fout.write(text.getBytes());
            fout.flush();
            fout.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. saveFile(InputStream uploadedInputStream, String serverLocation)
  2. saveFile(String content, String path)
  3. saveFile(String desEncryptTempFile, byte[] text)
  4. saveFile(String destinationFile, String contents)
  5. saveFile(String dir, String fileName, String data)
  6. saveFile(String fileName, byte[] bytes)
  7. saveFile(String filename, byte[] content)
  8. saveFile(String fileName, byte[] data)
  9. saveFile(String fileName, InputStream stream)