日期:2014-05-20 浏览次数:21242 次
public static List<Lorry> readData(){
String url = "http://www.17500.cn/getData/ssq.TXT";
URL u = null;
URLConnection conn = null;
InputStream is = null;
BufferedReader bReader = null;
List<Lorry> list = new ArrayList<Lorry>();
String[] line = null;
try {
u = new URL(url);
conn = u.openConnection();
is = conn.getInputStream();
bReader = new BufferedReader(new InputStreamReader(is));
while (bReader.ready()) {
Lorry lorry = new Lorry();
// line = bReader.readLine().split(" ");
// lorry.setMag(line[0]);
// lorry.setDate(line[1]);
// lorry.setRed1(line[2]);
// lorry.setRed2(line[3]);
// lorry.setRed3(line[4]);
// lorry.setRed4(line[5]);
// lorry.setRed5(line[6]);
// lorry.setRed6(line[7]);
// lorry.setBlue(line[8]);
// list.add(lorry);
System.out.println(bReader.readLine());
}
// for (Lorry l : list) {
// System.out.println(l.getDate());
//
// }
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
is.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return list;
import com.google.common.io.Resources;
List<String> records = Resources.readLines(new URL(url), Charset.forName("GBK"));