我正在非常困难地想弄清楚如何从我在文件路径中传递的对象中获取记录。
import java.util.ArrayList;
import edu.trident.cpt237.recordreaper.CabRecordReaper;
public class CabOrginazer implements CabInfo
{
private final String FARE = "";
private final String GAS = "";
private final String SERVICE = "";
private final String MILES = "";
private final double VALUE = 0.0;
CabRecordReaper reaper = new CabRecordReaper("C:/CabRecords/September.txt" );
public void cabOrginazer()
{
}
@Override
public Records getType() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getDate() {
// TODO Auto-generated method stub
return null;
}
@Override
public String CabId() {
// TODO Auto-generated method stub
return null;
}
@Override
public double getValue() {
// TODO Auto-generated method stub
return 0;
}
@Override
public double getPerGallonCost() {
// TODO Auto-generated method stub
return 0;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
我尝试使用扫描仪但是没有用,所以我把它拿出来了。我不能做任何其他方法,直到我能抓住收割机旁边的东西。 CabRecordReaper中唯一的方法是hasMoreRecord(),它确定文件中是否有更多行。
答案 0 :(得分:0)
我不太了解您的问题,但我认为您在阅读.txt文件时遇到了困难?
try (BufferedReader reader = Files.newBufferedReader(Paths.get("path here")) {
String line = null;
while ((line = reader.readLine()) != null) {
// Add your code here.
System.out.println(true);
}
} catch (IOException e) {
e.printStackTrace();
}