package org.springblade.modules.gzInfo.vo;

import java.lang.*;
import java.io.*;

public class Base64 {
	public static String byteConverterBASE64(File file){
		long size = file.length();
		byte[] imageByte = new byte[(int)size];
		FileInputStream fs = null;
		BufferedInputStream bis = null;
		try {
			fs = new FileInputStream(file);
			bis = new BufferedInputStream(fs);
			bis.read(imageByte);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			if(bis != null){
				try {
					bis.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(fs != null){
				try {
					fs.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return (new sun.misc.BASE64Encoder()).encode(imageByte);
	}

	public static void main(String[] args) {
		File file=new File("C:\\Users\\12709\\Pictures\\OIP-C.jfif");
		String str=Base64.byteConverterBASE64(file);
		System.out.println(str);
		System.out.println(str.length());
	}
}
