1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| public class CityDataServiceImpl implements CityDataService {
public List<City> listCity() throws Exception {
Resource resource = new ClassPathResource("citylist.xml"); BufferedReader br = new BufferedReader(new InputStreamReader(resource.getInputStream(), "utf-8")); StringBuffer buffer = new StringBuffer(); String line = "";
while ((line = br.readLine()) != null) { buffer.append(line); }
br.close();
CityList cityList = (CityList) XmlBuilder.xmlStrToObject(CityList.class, buffer.toString()); return cityList.getCityList(); } }
|