Java FileOutputStream Write saveResouce(String resourceName, String outputFile)

Here you can find the source of saveResouce(String resourceName, String outputFile)

Description

save Resouce

License

Mozilla Public License

Declaration

private static void saveResouce(String resourceName, String outputFile) throws IOException 

Method Source Code

//package com.java2s;
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

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

import java.io.OutputStream;

public class Main {
    private static void saveResouce(String resourceName, String outputFile) throws IOException {
        InputStream input = resourceName.getClass().getResourceAsStream(resourceName);
        OutputStream output;/*w ww .ja va 2  s .c  om*/
        output = new FileOutputStream(outputFile);
        writeFile(input, output);
        output.flush();
        output.close();
    }

    private static void writeFile(InputStream input, OutputStream output) throws IOException {
        byte[] buffer = new byte[1024];
        int bytesRead = 0;
        while ((bytesRead = input.read(buffer)) != -1) {
            output.write(buffer, 0, bytesRead);
        }
    }
}

Related

  1. saveInt16bit(String filename, int[] intData)
  2. saveIntArrayToFile(int[] array, File file)
  3. saveKeyToFile(String key)
  4. saveLongList(String file, Collection c, boolean append)
  5. saveProxyClass(String path, String proxyClassName, Class[] interfaces)
  6. saveStream(InputStream is, File output)
  7. saveStream(InputStream stream, File targetFile)
  8. saveStreamToFile(InputStream in, File outFile)
  9. saveStreamToFile(InputStream is, File destFile)