Use left and right arrow keys to adjust the split region size
Description
Description
Use left and right arrow keys to adjust the split region size
FileIO.java
TravelSystem.java
tours.txt
Tour.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.ArrayList;
import java.util.Scanner;
import java.io.FileReader;
import java.io.PrintWriter;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileIO
{
public static ArrayList<Tour> readFile(String filename)
throws FileNotFoundException, IOException
{
ArrayList<Tour> tours = new ArrayList<Tour>();
FileReader reader = new FileReader(filename);
Scanner scanner = new Scanner(reader);
while (scanner.hasNextLine())
{
String line = scanner.nextLine();
Tour tour = parseLine(line);
if (tour != null)
{
tours.add(tour);
}
}
scanner.close();
return tours;
}
public static void writeFile(String filename, ArrayList<Tour> tours)
throws FileNotFoundException;
{
// if (writer == null)
// return null;
PrintWriter writer = new PrintWriter(filename);
for (Tour tour : tours)
{
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.ArrayList;
import java.io.FileNotFoundException;
import java.io.IOException;
public class TravelSystem
{
private ArrayList<Tour> tours;
public void display()
{
if(tours != null)
{
for (Tour tour : tours)
{
System.out.println("aba" + tour);
}
}
else
{
System.out.println("there is no tour");
}
}
public static void main(String[] args)
throws FileNotFoundException, IOException
{
TravelSystem ts = new TravelSystem();
ts.run();
}
public void run()
throws FileNotFoundException, IOException
{
tours = FileIO.readFile("tours.txt");
display();
}
1
2
3
4
Venice,Rome,2,500
Rome,Milan,3,400
Milan,Geneva,4,700
Geneva,Hamburg,4,650
1
/home/FileIO.java All changes saved
Use up and down arrow keys to adjust the split region size
Click here to activate the terminal
Drop files here to upload