Java FileOutputStream Write saveToFile(String data, File file)

Here you can find the source of saveToFile(String data, File file)

Description

save To File

License

Open Source License

Declaration

public static void saveToFile(String data, File file) throws IOException 

Method Source Code

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

import java.io.File;

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

public class Main {
    public static void saveToFile(String data, File file) throws IOException {
        FileOutputStream fos = null;
        try {//from  w w  w. ja  va 2 s.  c o m
            fos = new FileOutputStream(file);
            fos.write(data.getBytes());
        } finally {
            if (fos != null)
                fos.close();
        }
    }

    public static void saveToFile(byte[] data, File file) throws IOException {
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(file);
            fos.write(data);
        } finally {
            if (fos != null)
                fos.close();
        }
    }
}

Related

  1. saveToFile(InputStream in, File dst)
  2. saveToFile(InputStream in, String fileName)
  3. saveToFile(InputStream stream, File file)
  4. saveToFile(String baseName, String extension, byte[] content)
  5. saveToFile(String data, File file)
  6. saveToFile(String fileName, String fileCode, File dir, String fileExtention)
  7. saveToFile(String filePath, InputStream in)
  8. saveToTextFile(String filename, byte[] text)
  9. SaveToZipSB(File file, String ZippedFile, StringBuilder sb)