Java Path File Read nio readManifest(Path path)

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

Description

read Manifest

License

Apache License

Declaration

public static Map<String, String> readManifest(Path path) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class Main {
    public static Map<String, String> readManifest(Path path) throws IOException {
        try (InputStream fileInput = Files.newInputStream(path);
                InputStream input = new BufferedInputStream(fileInput)) {
            Properties properties = new Properties();
            properties.load(input);/*  w w w  .j a v a  2s.c o  m*/

            Map<String, String> result = new HashMap<>(2 * properties.size());
            for (Map.Entry<?, ?> entry : properties.entrySet()) {
                result.put(entry.getKey().toString(), entry.getValue().toString());
            }

            return result;
        }
    }
}

Related

  1. readLinesFromFile(Path path)
  2. readLinesFromFileLazy(String path)
  3. readLinesOfFile(String path)
  4. readLineSP(String filePath, int line, int pos)
  5. readLinesToString(Path file)
  6. readPropertiesFile(Path path)
  7. readSheBang(Path script)
  8. readStringFromPath(Path path)
  9. readTextFile(Path p)