如何在 Java 中解密或读取我的 base64 .txt
文件?
import java.io.*;
import java.util.*;
public class BaseDec {
public static void main (String[]args)throws IOException{
System.out.print("Enter the file name with extension:");
Scanner sc = new Scanner(System.in);
File GuionFile = new File(sc.nextLine());
sc = new Scanner(File);
String GuionLine = sc.nextLine();
byte[] decodedArr = Base64.getDecoder().decode(File);
String decodedText = new String(decodedArr);
System.out.println(decodedText);
sc.close();
}
}
最佳答案
此代码片段适用于 JShell:
import org.codehaus.plexus.util.Base64;
import java.io.File;
import java.nio.file.Files;
File file = new File("base64test.txt");
System.out.println(new String(Base64.decodeBase64(Files.readAllBytes(file.toPath()))));
关于java - 解码 .txt 文件中的 Base64 时遇到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58350429/