-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileReader.java
More file actions
35 lines (33 loc) · 893 Bytes
/
FileReader.java
File metadata and controls
35 lines (33 loc) · 893 Bytes
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
package org.usfirst.frc.team3238.robot;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class FileReader
{
public static ArrayList<String> readFile(String fileName)
{
Scanner fileInput = null;
File file = null;
ArrayList<String> contents = null;
try
{
file = new File("/" + fileName);
fileInput = new Scanner(file);
contents = new ArrayList<String>();
String line = "";
while(fileInput.hasNextLine())
{
line = fileInput.nextLine();
contents.add(line);
}
} catch(IOException e)
{
System.out.println("Could not open " + fileName + "!");
} finally
{
fileInput.close();
}
return contents;
}
}