某个程序员闯关游戏的最后一关,有点费事,需要将一个二进制文件转换成ascii码,发现ascii码文件是Base64的加密文件,所以再用BASE64Decoder包(下载地址:https://pan.baidu.com/s/1slEQitf)进行Base64解码,得到的文件是一个压缩文件。
代码如下:
import Decoder.BASE64Decoder;
public class d1111 {
public static void main(String[] args) throws IOException {
game1111_9();
}
public static void game1111_9() throws IOException {
File file = new File("C:\\Users\\光\\Pictures\\11.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
StringBuffer sb = new StringBuffer();
String line = null;
while ((line = br.readLine()) != null) {
String[] codes=line.split(" ");
for(String code:codes){
char c=(char) Integer.parseInt(code, 2);
sb.append(c);
}
}
System.out.println(sb);
BASE64Decoder decoder = new BASE64Decoder();
byte[] decodeBuffer = decoder.decodeBuffer(sb.toString());
File decodeFile = new File("C:\\Users\\光\\Pictures\\decode.tar.gz");
FileOutputStream fileOutputStream = new FileOutputStream(decodeFile);
fileOutputStream.write(decodeBuffer);
fileOutputStream.close();
br.close();
}
}