org.lotus.Main.java Source code

Java tutorial

Introduction

Here is the source code for org.lotus.Main.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lotus;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.codec.binary.Base64;

/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, IOException {
        File folder = new File(System.getProperty("user.dir")).getParentFile();
        File inf = new File(folder, "img (1).png");
        FileInputStream in = new FileInputStream(inf);
        byte[] buffer = new byte[(int) inf.length()];
        in.read(buffer);
        in.close();
        String str = Base64.encodeBase64URLSafeString(buffer);
        buffer = Base64.decodeBase64(str);
        FileOutputStream out = new FileOutputStream(new File(folder, "out.png"));
        out.write(buffer);
        out.close();
    }

}