what I'm trying to do here is get what is inside of a data/txt file and store it into an array. Right now I'm just trying to do the String, but ultimately I will like to get everything in the file to output. This is what is inside the txt file:
Honduras 130 Tegucigalpa Cuba 100 Habanna
I will like for the output to be the same in java.
import java.io.File;
import java.util.Scanner;
import java.util.ArrayList;
public class ReadCountries2
{
public static void main(String [] args)throws Exception
{
String fName = "/Users/Edward Lavaire/Downloads/Countries.txt";
Scanner s = new Scanner(new File(fName));
String name [] = new String[6];
while(s.hasNext())
{
int i = 0;
name[i] = s.next();
System.out.println(name[i]);
i++;
}
}
}