Here you can find the source of loadProperties(Map
public static void loadProperties(Map<String, String> map, File file, String encoding) throws IOException
//package com.java2s; /*//from ww w .ja v a2s . com * Copyright (c) 2001-2011 Convertigo SA. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public License * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see<http://www.gnu.org/licenses/>. * * $URL$ * $Author$ * $Revision$ * $Date$ */ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; public class Main { public static void loadProperties(Map<String, String> map, File file, String encoding) throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding)); String key = null; String line; int cpt = 1; while ((line = br.readLine()) != null) { if (line.length() != 0) { if (cpt % 3 == 1) { key = line; } else if (cpt % 3 == 2) { map.put(key, line); } else { throw new IOException("The line number " + cpt + " must be empty (" + line + ")"); } } else { if (cpt % 3 != 0) { throw new IOException( "The line number " + cpt + " must not be empty (last key =" + key + ")"); } } cpt++; } } finally { if (br != null) br.close(); } } }