Java FileOutputStream Write saveBase64strToFile(String base64Str, String filePath)

Here you can find the source of saveBase64strToFile(String base64Str, String filePath)

Description

save Basestr To File

License

Open Source License

Declaration

public static void saveBase64strToFile(String base64Str, String filePath) throws IOException 

Method Source Code


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

import sun.misc.BASE64Decoder;

import java.io.*;

public class Main {
    public static void saveBase64strToFile(String base64Str, String filePath) throws IOException {
        BASE64Decoder decoder = new BASE64Decoder();
        byte[] b = decoder.decodeBuffer(base64Str);
        for (int i = 0; i < b.length; ++i) {
            if (b[i] < 0) {
                b[i] += 256;/*  w  w  w. j a  v  a 2  s  .  co  m*/
            }
        }
        OutputStream out = new FileOutputStream(filePath);
        out.write(b);
        out.flush();
        out.close();
    }
}

Related

  1. save(String f, byte[] data)
  2. save(String filename, byte[] bytes)
  3. save(String path, byte[] content, IProgressMonitor monitor)
  4. saveArray(byte[] pictureBytes, OutputStream stream)
  5. saveBase64Str2Disk(String base64Str, File file)
  6. saveBinaryFile(String fileName, byte[] buffer)
  7. saveByteArrayToFile(final File file, final byte[] array)
  8. saveByteFile(byte[] data, String filePath)
  9. saveBytes(byte[] b, File destFolder, String fileName, String suffix)