Tag: base64

如何在java中将blob图像转换为binarybase64?

我有来自DB的blob格式的图像,我在字节数组中保存blob图像并将其转换为二进制Base64格式。 为了将blob编码为二进制基数64,我使用下面的代码, byte[] imageByte = getblob();//from DB byte[] encodedImage = Base64.encodeBase64(imageByte); 有没有其他方法可以做到或正在以正确的方式做它请帮帮我?

sun.misc.BASE64Decoder在java应用程序中显示错误

在某些java文件中有一个用途: import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; 当我把那个java文件放在Eclipse IDE中时。 它不会检测这些文件。 但是这些包(sun.misc.BASE64Decoder,sun.misc.BASE64Encoder)都在rt.jar文件中。 在我的项目库中,“rt.jar”可用。 但为什么它会显示错误(eclipse中的红线)?

Java无法使用带图像的html发送电子邮件

我正在尝试使用带有两个图像的html发送电子邮件。 这两个图像从AngularJS客户端发送为base64字符串,如下所示: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAALuCAYAAAA9jTxNAAAgAElEQ 请注意,我已将base64字符串截断为太长。 String temp = baseString.split(“,”)[1]; byte[] tile = DatatypeConverter.parseBase64Binary(temp); BodyPart messageBodyPart = new MimeBodyPart(); InputStream inputStream = new ByteArrayInputStream(tile); DataHandler dataHandler = new DataHandler(new InputStreamDataSource(inputStream)); messageBodyPart.setDataHandler(dataHandler); messageBodyPart.setHeader(“Content-ID”, “”); multipart.addBodyPart(messageBodyPart); InputStreamDataSource: public class InputStreamDataSource implements DataSource { private InputStream inputStream; public InputStreamDataSource(InputStream inputStream) { this.inputStream = inputStream; } public InputStream getInputStream() { return […]

Android + Java从服务器上的URL获取图像并作为字符串传递给客户端:Base64解码和编码无法正常工作

在Java服务器中,我从外部服务URL获取图像,如: InputStream in = new java.net.URL(imageWebServiceURL).openStream(); String resultToCleint = org.apache.commons.codec.binary.Base64.encodeBase64URLSafeString(IOUtils.toByteArray(in)); 然后在Android上我解析它: byte[] imageAsBytes = Base64.decode(resultToCleint.getBytes(), Base64.DEFAULT); imageView.setImageBitmap(BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); 结果:图像未显示,不是服务器上或客户端上的错误/exception。 这里有什么问题? 编辑:在Android上我使用类android.util.Base64 谢谢,

从Base64编码的字符串中检索ECC公钥

我一直在尝试使用Base64编码的ECC公钥创建java.security.PublicKey的实例。 MainActivity.java @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { byte[] data = decodePublicKey(“AsIAEFjzIcX+Kvhe8AmLoGUc8aYAEAwf5ecREGZ2u4RLxQuav/A=”); PublicKey publicKey = loadPublicKey(“secp128r1”, data); Log.d(TAG, publicKey.toString()); } catch (SQLException | IOException | GeneralSecurityException e) { Log.e(TAG, e.getMessage(), e); } } private byte[] decodePublicKey(String s) throws UnsupportedEncodingException { return Base64.decode(s, Base64.DEFAULT); } public PublicKey loadPublicKey(String curve, byte[] data) throws […]

Java – Base64字符串输入和输出文本

我需要将包含base64编码文本的字符串写入文本文件,然后将该字符串从文本文件读回字符串变量。 我怎么能这样做,以免因编码问题而导致数据丢失?

如何从base64解码video?

我希望转换video在base64字符串,所以我转换migBase64方法通过我在Android的video它将video转换成字符串成功,但当我解码字符串到video然后它不正确转换video。 如果有人知道,请帮助我。 我尝试如下代码: String encodedString; //Decode Video To String File tempFile = new File(Environment.getExternalStorageDirectory()+ “/my/part/my_0.mp4”); byte fileContent[] = new byte[3000]; try { FileInputStream fin = new FileInputStream(tempFile); while (fin.read(fileContent) >= 0) { // b.append(Base64.encodeToString(fileContent, true)); encodedString = Base64.encodeToString(fileContent, true); } } catch (IOException e) { } //Encoding Video To String Successfully. //Decode String To Video […]

Java缓冲了用于流的base64编码器

我有很多PDF文件,我需要使用base64编码其内容。 我有一个Akka应用程序,它将文件作为流获取并分发给许多工作人员以编码这些文件并返回每个文件的字符串base64。 我有一个基本的编码解决方案: org.apache.commons.codec.binary.Base64InputStream; … Base64InputStream b64IStream = null; InputStreamReader reader = null; BufferedReader br = null; StringBuilder sb = new StringBuilder(); try { b64IStream = new Base64InputStream(input, true); reader = new InputStreamReader(b64IStream); br = new BufferedReader(reader); String line; while ((line = br.readLine()) != null) { sb.append(line); } } finally { if (b64IStream != null) […]

Java 8中basic和url base64编码之间的区别

Java 8 Base64库有两个可用于构建URI的变体:“Basic”和“URL和文件名安全”。 文档指向RFC 4648表2作为差异的解释。 在阅读规范之后,我仍然不清楚两种编码之间的实际区别是什么:两种标准都得到“广泛”支持? 具体的浏览器呢? 是否建议对数据URI编码使用URL和文件名安全编码? 是否存在已知的支持限制?

使用超大的json文件。 总是内存不足

如何使用带有jackson的流API json? 请参阅下面的代码: ObjectMapper mapper = new ObjectMapper(); Map map = new HashMap(); List list = new ArrayList(); // Get images in database try { Class.forName(DRIVER); connection = DriverManager.getConnection(URL, USER, PASSWORD); Statement s = connection.createStatement(); ResultSet r = s.executeQuery(“select * from images”); while (r.next()) { byte[] imageBytes = r.getBytes(“image”); String imageBase64 = DatatypeConverter.printBase64Binary(imageBytes); list.add(imageBase64); } […]