Java Path File Read nio loadJSON(Path path)

Here you can find the source of loadJSON(Path path)

Description

load JSON

License

Open Source License

Declaration

public static JsonNode loadJSON(Path path) throws JsonProcessingException, IOException 

Method Source Code


//package com.java2s;

import java.io.IOException;

import java.io.Reader;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {
    private static final ObjectMapper JSON_MAPPER = new ObjectMapper();

    public static JsonNode loadJSON(Path path) throws JsonProcessingException, IOException {
        try (final Reader input = Files.newBufferedReader(path, StandardCharsets.UTF_8);) {
            return loadJSON(input);
        }//from ww  w  .  jav  a 2s .  c o m
    }

    public static JsonNode loadJSON(Reader input) throws JsonProcessingException, IOException {
        return JSON_MAPPER.readTree(input);
    }
}

Related

  1. loadFile(final Path filePath)
  2. loadFile(final Path p)
  3. loadFile(Path file)
  4. loadFile(String path)
  5. loadFromFile(Path path)
  6. loadProperties(Path filePath)
  7. loadProperties(Supplier classLoader, String classpathResource)
  8. loadStrings(Path thePath)
  9. loadStringsFromFile(String pathToFile)