Java tutorial
package cloudRessourceBase; /* * Copyright (c) 2014, Denis Weerasiri All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import com.google.gson.Gson; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; /** * User: denis * Represent utility classes for convert the files to json objects */ public class DataUtil { private static final Logger log = LoggerFactory.getLogger(DataUtil.class); public static Map convertJSONToMap(String json) { Gson gson = new Gson(); Map<String, String> map = new HashMap<String, String>(); map = (Map<String, String>) gson.fromJson(json, map.getClass()); return map; } public static String fileToString(File aFile) throws IOException { String fileContent = FileUtils.readFileToString(aFile); return fileContent; } }