public static void getClientUpdate() {
try {
String inputLine;
double version = 0;
URL url = new URL("http://ds-forums.com/client/version.txt");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
version = inputLine;
System.out.println("The version is: " + version);
} catch (Exception x) {
System.out.println(x);
}
}
这听起来很愚蠢,但我有一个包含双精度型的文本文件,我想将它保存为双精度型。相反,它需要一个字符串。我做错了吗?还是仅仅需要添加几个步骤?从URL读取,将数据存储为double?
想知道为什么他不能用一个DataInputStream装饰url.openStream()并使用readDouble()? – 2011-01-18 22:27:43