Java FileOutputStream Create writeFile(InputStream inputFile, String path, String fullFileName)

Here you can find the source of writeFile(InputStream inputFile, String path, String fullFileName)

Description

Writes an file in a specific folder in the web server.

License

Open Source License

Parameter

Parameter Description
inputFile The input file to be write into the folder.
path The full path where the file will be wrote.
fullFileName The file name with its extension name.

Exception

Parameter Description
IOException The I/O exception.

Declaration

public static void writeFile(InputStream inputFile, String path, String fullFileName) 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;
import java.io.InputStream;
import java.io.OutputStream;

public class Main {
    /**//from  w ww .  j a  v  a 2  s . c  o m
     * Writes an file in a specific folder in the web server.
     * 
     * @param inputFile
     *            The input file to be write into the folder.
     * @param path
     *            The full path where the file will be wrote.
     * @param fullFileName
     *            The file name with its extension name.
     * @throws IOException
     *             The I/O exception.
     */
    public static void writeFile(InputStream inputFile, String path, String fullFileName) throws IOException {
        // creating objects to be wrote into the folder
        File file = new File(path + fullFileName);
        OutputStream outputFile = new FileOutputStream(file);

        // writing the file byte per byte
        byte buf[] = new byte[1024];
        int length;
        while ((length = inputFile.read(buf)) > 0) {
            outputFile.write(buf, 0, length);
        }

        // closing files
        inputFile.close();
        outputFile.close();
    }
}

Related

  1. writeFile(File outFile, ZipInputStream zipInputStream, ZipEntry entry)
  2. writeFile(FileOutputStream fileoutputstream, byte abyte0[], int i)
  3. writeFile(final String filename, final byte[] data)
  4. writeFile(final String fileNamePath, final byte[] daten)
  5. writeFile(InputStream in, File file)
  6. writeFile(InputStream inputStream, String filename, long lastModified)
  7. writeFile(InputStream is, File file)
  8. writeFile(InputStream is, File outFile)
  9. writeFile(InputStream srcStream, File destFile)