Java BufferedReader Read loadMetadata(File file)

Here you can find the source of loadMetadata(File file)

Description

load Metadata

License

Open Source License

Declaration

public static Map<String, Object> loadMetadata(File file) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.*;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static Map<String, Object> loadMetadata(File file) throws IOException {
        StringBuilder metadataBuilder = new StringBuilder();
        BufferedReader reader = new BufferedReader(new FileReader(file));
        String line;/*w  w  w  .  j  a v  a  2 s . c om*/
        while ((line = reader.readLine()) != null) {
            metadataBuilder.append(line).append('\n');
        }
        reader.close();
        Gson gson = new Gson();
        return gson.fromJson(metadataBuilder.toString(), new TypeToken<HashMap<String, Object>>() {
        }.getType());
    }
}

Related

  1. loadList(File f, String enc)
  2. loadList(final File file)
  3. loadList(String listName)
  4. loadListFromTextFile(String filename, String defaultitem, String linePrefix, String lineSuffix)
  5. loadLongArray(BufferedReader in)
  6. loadMetaFile(File metaFile)
  7. loadMimeTypes(Reader in, Map extMap, Map mimeMap)
  8. loadModel(String fileName, Hashtable dictionary, Hashtable> modelPairs)
  9. loadNameMap(String mapName, boolean reverseMap)