aoscici2000
V2EX  ›  Java

如何获得文件 application/msword, image/png 这种类型信息

  •  
  •   aoscici2000 · Jun 10, 2019 · 3342 views
    This topic created in 2725 days ago, the information mentioned may be changed or developed.

    String str = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(path)));

    在保存 base64 字符串的时候缺少了前面那一段信息, 那小段通过什么获取?

    2 replies  •  2019-06-11 17:24:53 +08:00
    LGA1150
    LGA1150
    Jun 10, 2019
    1
    这是 MIME Type,可以用 Files.probeContentType(path)
    aoscici2000
    aoscici2000
    OP
    Jun 11, 2019
    2
    @LGA1150 可以了, 谢谢哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4120 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 09:13 · PVG 17:13 · LAX 01:13 · JFK 04:13
    ♥ Do have faith in what you're doing.