Let's get started with a program that reads a file!
- Open Eclipse
- Right-Click on your
edu.buffalostate.cis425.fa10.exercises.src
package
- Choose:
File -> New -> file
- In the
Name:
textbox type: teams
- Click:
Finish
- Copy the
teams.txt
File (txt) code (below)
- Paste that code into your new teams.txt file in the editor
- Right-Click on your
edu.buffalostate.cis425.fa10.exercises.assignments
package
- Choose:
File -> New -> class
- In the
Name:
textbox type: ReadFile
- Click:
Finish
- Copy the
ReadFile.java
Template (Java) code (below)
- Paste that code into your new ReadFile class in the editor
- Change both occurrences of put-your-username-here
- Replace blank on line after the:
for (String item : teams) {
line with:
String[] strParts = item.split( ", " );
- Click the Run icon
ReadFile.java
Template (Java)
teams.txt
File (txt)
ReadFile
Class Output