import java.awt.Graphics;
import java.awt.List;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundEsxception;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class Benford {
static Object i = null;
static ArrayList<String> list = new ArrayList<String>();
private static String data;
public static void BenfordPercents() {
int one = 0;
int two = 0;
int three = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
return;
}
public static void main(String[] args) throws IOException {
DrawingPanel g = new DrawingPanel(500, 500);
Graphics brush = g.getGraphics();
String popData = null;
readCount(popData);
BenfordPercents();
}
public static void readCount(String popdata) throws IOException {
System.out.println("Please make sure the data file is name popData.txt");
System.out.println("We are loading popData.txt...");
Scanner console = new Scanner(System.in);
// Scanner console = new Scanner((new File("popData.txt")));
try {
i = new FileInputStream("popData.txt");
} catch (FileNotFoundException e) {
System.out.println("We cannot locate popData.txt");
System.out.println("Please make sure popData.txt is in the same location" + " as your code file!");
return;
}
System.out.println("popData.txt has loaded!");
System.out.println("");
System.out.println("Please press enter to show data!");
data = console.nextLine();
File file = new File(popdata + ".txt");
FileInputStream fis = new FileInputStream("popdata.txt");
byte[] flush = new byte[1024];
int length = 0;
while ((length = fis.read(flush)) != -1) {
list.add(new String(flush));
// System.out.println(new String(flush));
// System.out.println(list.toString());
}
// Scanner x = new Scanner((new File("popData.txt")));
// while(x.hasNext()){
// list.add(x.next());
// }
fis.close();
}
}
I have a text document with all the numbers of populiation from this link here: https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population
The text document looks like this:
China 1369480000
India 1270250000
United 320865000
Indonesia 255461700
Brazil 204215000
Pakistan 189607000
..etc
..etc
the list is pretty long.
and when I try to store all of these numbers into an array list and I try to print the array list size it just returns 4?