开发者社区> 问答> 正文

将Base64字符串转换为字符串数组

我正在使用request.getParameter并获取此值:

[ "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAA0NDQ0ODQ4QEA4UFhMWFB4bGRkbHi0gIiAiIC1EKjIqKjIqRDxJOzc7STxsVUtLVWx9aWNpfZeHh5e+tb75+f8BDQ0NDQ4NDhAQDhQWExYUHhsZGRseLSAiICIgLUQqMioqMipEPEk7NztJPGxVS0tVbH1pY2l9l4eHl761vvn5///AABEIBJgHKAMBIgACEQEDEQH/xACAAAEBAAMBAQEAAAAAAAAAAAAAAQIDBQQGBxABAAICAQIGAgEEAwEAAwEBAAECAxEEEiEFExQxQVEVIjIjUmFxM0KBJDRigkNEAQEBAQEBAAAAAAAAAAAAAAAAAQIDBBEBAAIDAQACAwEBAQAAAAAAAAERAhITUQMhMUFhIjJC/9oADAMBAAIRAxEAPwDYxmWFrREPPbKwN1sjyXvNlm20RWrpj6WKx9NuliBSGaRDKATohl0x9KygE0MgGHTHyTWPpmmgSKx9M4WAGMxuEisNiAw6I+liumSTIBpNwnUDLpj6NMYsz3sFiGWkhQYTWGUVDcAaRdgGjULokGOmUGlBU1CgjHREMlATpUUYdMfSxCqBCLtAYzVOiIZMtAwZmlBhrZ0wy0AnTB2hlBMA1ztrmky9GgV5a8eN7lviIrHaGbXedR2Bj1E7lrx1tM7l6dAx6YNM9GgTSqCJqDUKKJpQBF0KDHR2hkxmAVJhQGOliqgIq6AY6NQyUGOhUBTSKBoUBDQoJpNM0BDTJAY6TTKCYBgy0ul0DDRpnpdAw0rLRoGBpnpNAxVdEQCiroGEwsQugAlQGOl0ugEVRARkAxUZAhpVUTQqghpQE0aUTvs3ICJG2cADLsTMAIwtLGIsA0yiJXQAsQAIEAC7UAXTZWsQAjZoBUAAf/2Q==", "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAA0NDQ0ODQ4QEA4UFhMWFB4bGRkbHi0gIiAiIC1EKjIqKjI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换为数组?

虽然当我使用时,request.getParameterValues("jsondata");我得到这个值 [Ljava.lang.String;@8892fd8,这不是我想要的。如何转换为数组?

展开
收起
小六码奴 2019-08-17 14:51:58 2835 0
1 条回答
写回答
取消 提交回答
  • 该jsondata值是JSON文本。它以#开头[,这意味着它是一个JSON数组。

    要处理它,您应该使用JSON解析器。请参见如何在Java中解析JSON。

    一旦你解析它,你应该有一个String[]或一个List ,有2个值。

    两个值都data:image/jpeg;base64,以Base-64编码的二进制数据(JPEG图像)开始。

    假设你有Java 8或更高版本,请使用Base64该类将其解码为a byte[]。

    您现在拥有2个JPEG图像,采用2字节数组的形式。

    2019-08-17 14:52:42
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载