Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[source] Data_file_Uri coded by_Hu3c0 filter_list
Author
Message
[source] Data_file_Uri coded by_Hu3c0 #1
Hi brothers today I want to share with all of you this simply code Why...? because the best way to learn for me it's read and read a lots off code.
Okey without more preambles this code give you a base64 data image from whatever image or gif in your pc or url. What does the code? in the
example html has been explained.
Quote:import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Base64;

import java.util.Scanner;



public class File_Uri_Base {


public static void main(String[] args) throws FileNotFoundException, IOException {

Scanner sc = new Scanner(System.in);
System.out.println("Introduce the image Path please...");
String inkey= sc.nextLine();
File fl= new File (inkey);
FileInputStream fis = new FileInputStream(fl);
byte [] getbyte=JavaUtils.getBytesFromStream(fis);
String encoded = Base64.getEncoder().encodeToString(getbyte);
String outfile="<html><body><img src=\""+"data:image/png;base64,"+encoded+"\"></body></html>";

File f = new File("/home/Hu3c0/Desktop/image.html");
try (FileWriter fw = new FileWriter(f)) {
fw.write(outfile);
fw.flush();
}
I hope you like my friends and I hope would be helpfull
[Image: oAnNAVY.png]

Reply







Users browsing this thread: 1 Guest(s)