mirror of
https://gitee.com/jzsw-it/yexuejc-base.git
synced 2025-06-06 22:04:04 +08:00
变更Base64使用包,使其兼容openjdk11
This commit is contained in:
parent
556f2a49d2
commit
3987f982be
@ -1,13 +1,12 @@
|
|||||||
package com.yexuejc.base.util;
|
package com.yexuejc.base.util;
|
||||||
|
|
||||||
import sun.misc.BASE64Encoder;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.nio.MappedByteBuffer;
|
import java.nio.MappedByteBuffer;
|
||||||
import java.nio.channels.FileChannel;
|
import java.nio.channels.FileChannel;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.zip.CRC32;
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
@ -300,8 +299,12 @@ public class FileUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// 对字节数组Base64编码
|
// 对字节数组Base64编码
|
||||||
BASE64Encoder encoder = new BASE64Encoder();
|
return new String(Base64.getEncoder().encode(data));
|
||||||
return encoder.encode(data);
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String s = base64(new File("Z:\\NAS\\04.coding\\yexuejc\\yexuejc-base"));
|
||||||
|
System.out.printf( s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.yexuejc.base.util;
|
package com.yexuejc.base.util;
|
||||||
|
|
||||||
import sun.misc.BASE64Decoder;
|
|
||||||
import sun.misc.BASE64Encoder;
|
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.imageio.ImageReader;
|
import javax.imageio.ImageReader;
|
||||||
@ -11,6 +9,7 @@ import java.net.HttpURLConnection;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.Proxy;
|
import java.net.Proxy;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,8 +46,7 @@ public class ImgUtil {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// 对字节数组Base64编码
|
// 对字节数组Base64编码
|
||||||
BASE64Encoder encoder = new BASE64Encoder();
|
return new String(Base64.getEncoder().encode(data.toByteArray()));
|
||||||
return encoder.encode(data.toByteArray());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -237,7 +235,7 @@ public class ImgUtil {
|
|||||||
* @return String 编码后的字符串
|
* @return String 编码后的字符串
|
||||||
*/
|
*/
|
||||||
public static String encode(byte[] bytes) {
|
public static String encode(byte[] bytes) {
|
||||||
return new BASE64Encoder().encode(bytes);
|
return new String(Base64.getEncoder().encode(bytes));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user