1 package org.objectweb.petals.engine.clock; 2 3 import java.io.BufferedReader ; 4 import java.io.IOException ; 5 import java.io.InputStream ; 6 import java.io.InputStreamReader ; 7 import java.util.HashMap ; 8 9 public class TimeZonesMap { 10 private HashMap <String ,Integer > data; 11 12 public TimeZonesMap(InputStream in) throws IOException { 13 BufferedReader reader = new BufferedReader (new InputStreamReader (in)); 14 while(reader.ready()){ 15 String line=reader.readLine(); 16 int separatorIdx=line.indexOf(':'); 17 String city=line.substring(0,separatorIdx-1); 18 Integer timeZone=Integer.parseInt(line.substring(separatorIdx+1)); 19 data.put(city,timeZone); 20 } 21 } 22 23 public HashMap <String , Integer > getData() { 24 return data; 25 } 26 27 public void addTimeZone(String city, Integer timeZone) { 28 data.put(city,timeZone); 29 } 30 31 public Integer getTimeZone(String city){ 32 return data.get(city); 33 } 34 35 } 36 | Popular Tags |