小弟菜鸟 新学Java
要求完成一个类public class TimeTableReader {
/* OVERVIEW: Reads a Timetable from a text file.
public TimeTableReader(String filename) throws FileNotFoundException, IOException {/*Creates a timetable reader that will read from the text file fileName.
*/ } public timetable read() throws IOException, FormatException, InvalidTimeException, InvalidDurationException {
}
}其中 timetable 有另一个class timetable定义
小弟不明白这个需要完成的类各部分要写什么内容
TimeTableReader(String filename) 方法 是要做什么 怎么创建一个新的reader
public timetable read() 是要做什么 read没有参数
小弟明白怎么完成这个读文件的 过程 只是不知道 怎么放
下边是小弟写的 public TimeTableReader(string filename){
BufferedReader br = new BufferedReader (new FileReader("filename"));
String line = br.readLine();
while (line != null){
StringTokenizer st = new StringTokenizer (line);
while (st.hasMoreTokens()){
int i = st.countTokens();
String[] arr = new String[i];
for (int j = 0; j < i;j++)
{
arr[j] = st.nextToken().trim();
}
String no = arr[0];
String t = arr[1];
String rt = arr[2];
String ad = arr[3];
FLight job = new job (no,t,rt,ad);
TimeTable readin = new TimeTable();
readin.add(job);
}
}
}
要求完成一个类public class TimeTableReader {
/* OVERVIEW: Reads a Timetable from a text file.
public TimeTableReader(String filename) throws FileNotFoundException, IOException {/*Creates a timetable reader that will read from the text file fileName.
*/ } public timetable read() throws IOException, FormatException, InvalidTimeException, InvalidDurationException {
}
}其中 timetable 有另一个class timetable定义
小弟不明白这个需要完成的类各部分要写什么内容
TimeTableReader(String filename) 方法 是要做什么 怎么创建一个新的reader
public timetable read() 是要做什么 read没有参数
小弟明白怎么完成这个读文件的 过程 只是不知道 怎么放
下边是小弟写的 public TimeTableReader(string filename){
BufferedReader br = new BufferedReader (new FileReader("filename"));
String line = br.readLine();
while (line != null){
StringTokenizer st = new StringTokenizer (line);
while (st.hasMoreTokens()){
int i = st.countTokens();
String[] arr = new String[i];
for (int j = 0; j < i;j++)
{
arr[j] = st.nextToken().trim();
}
String no = arr[0];
String t = arr[1];
String rt = arr[2];
String ad = arr[3];
FLight job = new job (no,t,rt,ad);
TimeTable readin = new TimeTable();
readin.add(job);
}
}
}
解决方案 »
- 两个LINKEDLIST里面的东西怎么相加。。??
- 哪位兄弟看看:输出的结果如何解释?(第二个),为什么如此不同呢?
- 看这个程序关于static变量的问题
- 多线程的同步问题,欢迎指教。
- 不明白是什么意思~~
- 新手求教一个问题,请大家来帮忙看看,实在是挡不住我的好奇心
- 安装jbuilder7的Web Service Kit for Java Preview Release3后,总让我注册这个东西,请问到那可以找到license
- 【很急啊!!!!!!!!!!!!!!】
- 为什么不起作用呢?等了半天了都没人回答,高手都哪去了?
- 一个正则表达式问题
- 关于类和方法的基本问题 在线等
- JTextPane 在画图的时候透明,但是上面的文本也变得透明了,如何让文本不透明呢?
“先定义一个成员变量fileName,构造器里面,只进行fileName的初始化。而文件读取的代码放到read()方法中去,读取文件的文件名就是成员变量fileName,只不过read()方法最后要返回TimeTable的实例。”对不起 接着一个很弱智的问题
先定义一个成员变量fileName 怎么做
麻烦你能帮我修改一下么