Java FileOutputStream Write saveTemp(final byte[] data, final String suffix)

Here you can find the source of saveTemp(final byte[] data, final String suffix)

Description

save Temp

License

Apache License

Declaration

private static File saveTemp(final byte[] data, final String suffix) throws IOException 

Method Source Code

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

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

public class Main {
    private static File saveTemp(final byte[] data, final String suffix) throws IOException {
        final File tempFile = File.createTempFile("afirma", suffix); //$NON-NLS-1$
        tempFile.deleteOnExit();// ww  w  .j a  v  a2  s. c om
        if (saveFile(tempFile, data)) {
            return tempFile;
        }
        return null;
    }

    private static boolean saveFile(final File file, final byte[] dataToSave) throws IOException {
        final FileOutputStream fos = new FileOutputStream(file);
        fos.write(dataToSave);
        fos.close();
        return true;
    }
}

Related

  1. saveStreamToFile(InputStream is, File destFile)
  2. saveStringIntoFile(File file, String contents)
  3. saveStringIntoFile(String filePath, String contents)
  4. saveStringsList(String file, Collection c)
  5. saveStringToFile(File file, String content, String charset)
  6. saveTempFile(String xmlSource, String fileName)
  7. saveTextContentInFile(String content, File file)
  8. saveTextToFile(String fileName, String content)
  9. saveTo(InputStream in, String fileName)