请教各位大神,我用java将获取到的数据不停地更新到文本文件。希望用my

请教各位大神,我用java将获取到的数据不停地更新到文本文件。希望用mysql数据库存储该文本文件中的数据,怎样才能够做到在mysql中实时地自动更新这些数据呢?

我的思路是这样的:把读取的每一行放到一个对象里。然后用Collections.sort()排序。主要代码如下: class MyRow { private String name; // 名字 private double length; // 长度 private double weight; // 重量 private double power; // 威力 private double price; // 价格 public MyRow(String x) { String[] ss = x.split("\t"); name = ss[0].trim(); length = Double.parseDouble(ss[1]); weight = Double.parseDouble(ss[2]); power = Double.parseDouble(ss[3]); price = Double.parseDouble(ss[4]); } public String toString() { return name + "\t" + length + "\t" + weight + "\t" + power + "\t" + price; } public String getName() { return name; } public double getLength() { return length; } public double getWeight() { return weight; } public double getPower() { return power; } public double getPrice() { return price; } } class MyData { // 内部类,“裁判”类,用于裁决Vector中的对象的比较大小问题 class CaiPan implements Comparator { private int type; public CaiPan(int type) { this.type = type
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答