System.out.printf("输入导出地址(两个文件都会在这个目录下):");
String toBothPath = scanner.next() ;
base64StringToImage(getImageBinary(path), toBothPath);
if(base64StringToTxt(getImageBinary(path), toBothPath).equals("success")){
System.out.println();
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** 导出成功 **\n");
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** Thanks!!! **\n");
System.out.printf("\t\t↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n");
}
} else {
System.out.println();
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** 您输入的编号无效!!! 程序意外退出了!!! **\n");
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** Thanks!!! **\n");
System.out.printf("\t\t↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n");
}
} else {
System.out.println();
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** Thanks!!! **\n");
System.out.printf("\t\t↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n");
}
}
}
static String getImageBinary(String path){
File f = new File(path);
BufferedImage bi;
try {
bi = ImageIO.read(f);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
byte[] bytes = baos.toByteArray();
return encoder.encodeBuffer(bytes).trim();
} catch (IOException e) {
// e.printStackTrace();
System.out.println();
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** 您输入的地址无效!!! 程序意外退出了!!! **\n");
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** Thanks!!! **\n");
System.out.printf("\t\t↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n");
}
return "" ;
}
static String base64StringToImage(String base64String, String path){
try {
byte[] bytes1 = decoder.decodeBuffer(base64String);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes1);
BufferedImage bi1 =ImageIO.read(bais);
File w2 = new File(path + "/wjp.png");
ImageIO.write(bi1, "jpg", w2);
} catch (Exception e) {
// e.printStackTrace();
System.out.println();
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** 您输入的地址无效!!! 程序意外退出了!!! **\n");
System.out.printf("\t\t*********************************************\n");
System.out.printf("\t\t** Thanks!!! **\n");
System.out.printf("\t\t↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑\n");
return "err" ;
}
return "success" ;
}
static String base64StringToTxt(String base64String, String path){
File filename = new File(path + "/wjp.txt");
RandomAccessFile mm = null ;
try {
mm = new RandomAccessFile(filename,"rw");
try {
mm.writeBytes(base64String);
} catch (IOException e) {
//e.printStackTrace();
System.out.println();
System.out.printf("\t\t*********************************************\n");
推荐阅读
- 泡洗粉洗衣服安全吗 泡洗粉洗衣服对人体有害吗
- 如何选择适合自己的电脑图片软件 电脑图片软件哪个好
- 电脑图片无法正常显示的原因及解决方法 为什么电脑的图片显示不出来
- 电脑长时间休眠对硬件有什么影响 电脑不关机只休眠
- 电脑内存不足如何应对 电脑没内存了怎么办啊
- 如何设置电脑以便使用U盘安装系统 u盘装系统怎样先对电脑设置
- 电脑为什么无法显示图片属性 电脑为什么没有图片属性
- 如何减少电脑辐射对胎儿的影响 电脑副射对胎儿的影响
- 怀孕初期电脑使用注意事项 怀孕初期经常对着电脑
- 做菜经常放味精是不是会对身体不好?为什么?