aoscici2000
V2EX  ›  Java

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

  •  
  •   aoscici2000 · Jun 10, 2019 · 3120 views
    This topic created in 2599 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
        1
    LGA1150  
       Jun 10, 2019
    这是 MIME Type,可以用 Files.probeContentType(path)
    aoscici2000
        2
    aoscici2000  
    OP
       Jun 11, 2019
    @LGA1150 可以了, 谢谢哈
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5665 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 156ms · UTC 06:29 · PVG 14:29 · LAX 23:29 · JFK 02:29
    ♥ Do have faith in what you're doing.