不好意思各位大侠,上一贴数据给的时候是随便写的,真正的数据如下所示(是用逗号分隔的)的:
0.0,0.0,50.500
100.0,0.0,50.505
200.0,0.0,50.503
0.0,100.0,50.502
100.0,100.0,50.509
200.0,100.0,50.500
0.0,200.0,50.501
100.0,200.0,50.506
200.0,200.0,50.501
0.0,0.0,20.302
100.0,0.0,20.303
200.0,0.0,20.307
0.0,100.0,20.306
100.0,100.0,20.303
200.0,100.0,20.306
0.0,200.0,20.301
100.0,200.0,20.304
200.0,200.0,20.307
在JAVA中怎样把这个TXT文档中的每行的三个数据分别读到X,Y,Z三个动态数组
希望把数据做成动态处理添加到数组中,谢谢!
0.0,0.0,50.500
100.0,0.0,50.505
200.0,0.0,50.503
0.0,100.0,50.502
100.0,100.0,50.509
200.0,100.0,50.500
0.0,200.0,50.501
100.0,200.0,50.506
200.0,200.0,50.501
0.0,0.0,20.302
100.0,0.0,20.303
200.0,0.0,20.307
0.0,100.0,20.306
100.0,100.0,20.303
200.0,100.0,20.306
0.0,200.0,20.301
100.0,200.0,20.304
200.0,200.0,20.307
在JAVA中怎样把这个TXT文档中的每行的三个数据分别读到X,Y,Z三个动态数组
希望把数据做成动态处理添加到数组中,谢谢!
解决方案 »
- Socket传输问题
- 一个小程序, 编译时的错误???
- java select @@IDENTITY 取值为题
- 大家来分析一下这个程序的输出结果
- java 调用 SQL 代码怎么写
- 我的程序在jBuilder中运行可以发出邮件,打了包就发不出邮件了,为什么啊
- 急急急!!!!!!! 如何在 JFrame 或者 应用程序 里播放声音?????麻烦了
- 小问题!!
- 有哪位兄弟知道水晶报表9.0(Crystal)企业版中的那个Report Application Server (RAS)的密码是多少??高分求救。
- Jbutton添加图片的问题 请帮我看下为什么我运行了图片还是没有显示出来呢?
- java判断文本末尾的回车符
- java的反射
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
import java.lang.String;import javax.swing.JFrame;public class Test extends JFrame
{ static List x = new ArrayList();
static List y = new ArrayList();
static List z = new ArrayList(); public static void main(String[] args) throws Exception
{
BufferedReader in = new BufferedReader(new FileReader("b.txt"));
String ss;
while ((ss = in.readLine())!=null)
{
String[] s =ss.split(",");
x.add(s[0]);
y.add(s[1]);
z.add(s[2]);
} System.out.println(x);
System.out.println(y);
System.out.println(z); in.close();
}} 报错:--------------------Configuration: <Default>--------------------
D:\example for java applet\Test.java:22: cannot resolve symbol
symbol : method split (java.lang.String)
location: class java.lang.String
String[] s =ss.split(",");
^
1 error
static List y = new ArrayList();
static List z = new ArrayList(); public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new FileReader("F://bb.txt"));
String ss;
while ((ss = in.readLine()) != null) {
String[] s = ss.split(" ");
x.add(s[0]);
y.add(s[1]);
z.add(s[2]);
s = null;
} System.out.println(x);
System.out.println(y);
System.out.println(z); in.close();
}}[0, 0, 1]
[0.5, 0.8, 0.9]
[100, 200, 230]
…………………………
不行。split方法。是1.4版本开始的。换吧。学java的得跟上步骤啊
public static void main(String[] args) throws IOException {
List<Double> x = new ArrayList<Double>();
List<Double> y = new ArrayList<Double>();
List<Double> z = new ArrayList<Double>();
BufferedReader in = new BufferedReader(new FileReader("c:\\test.txt"));
String str = null;
while ((str = in.readLine()) != null) {
String[] s = str.split(",");
x.add(Double.valueOf(s[0]));
y.add(Double.valueOf(s[1]));
z.add(Double.valueOf(s[2]));
}
System.out.println(x);
System.out.println(y);
System.out.println(z);
in.close();
}
1.3 的jdk 丛哪可以download ?
呵呵,玩笑了
6楼的可以借鉴一下