having an error reading from a file in java -


Need help fixing this error I am trying to print the array length of string country names

I am reading from a CVS file and I get the error above. Below is my code:

  import java.io. *; Import java.util.Scanner; Public class CSVReader {// string countryname; String [] countryname; Int years labels; Int [] number of years; Double Cellular DataTable; Double [] [] tables; Scanner scan; Public CSVReader (string filename) // file notfound exception {set up (filename); } Private zero set up (string filename) // file notfound exception {file file = new file (filename) throws; {String input = ""; Scan = new scanner (file); Scan.nextLine (); While ((input = scan.nextLine ())! = Null {string [] countryname = input.split (","); // int a = integer Parasont (country name [1]); Println (countryNames [0]); //System.out.println(a); } Scan.close (); } Hold (FileNotFoundException e) {System.out.println (e); }} Public string [] getCountryNames () {return countryname; }   

Below is my testCSV class file:

  Test class for test class = testCSVReader {/ ** * includes CSVReader. * / Public static zero main (string [] args) {final string FILENAME = "data / cellular .csv"; Mac OS X / Final string FILENAME = "// directory path for" Data \ Cellular .csv "; // Directory path for Windows OS (i.e. operating system) csvrder parser = new csvrder (filename); String [] countryNames = parser.getCountryNames (); Println (countryNames.length); }   

My CSV file looks like this: This is a summary because I did not want to print entire 252 countries. In fact, I take 252 countries and keep it in a string array, store them in array and statistics within 2D double array of cellular data within each country. I am new to programming and would like to know whether I am going in the right direction and if you do not name the country in string array, then how many years will it be in int and the data in a 2D double array.

The CVS file looks like this:

  Number of countries of world development indicators, 252 country names, 1960, 61, 1962, 1963, 1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988, 1989,1990,1991, 1992, 1939, 1994, 1951, 1996, 1979, 99, 19, 99, 2000, 2000, 2000, 2002, 2007, 2007, 20000, 2002, 2007, 2007, 2007, 200 9, 2009, 2009, 011,2012 Aruba, 0, 0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0.0,029310471,0,0,2.138784453 3.605985937,3.98141538,6.16435217,13.48254011,16.50927821,57.05427692,65.05605558,72.10431377,99.64250268,103.3849507,108.1325002,112.2180618,119.2038996,126.2103374,129.72824, 0,131.8565401 Andorra, 0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0,0,0,0,0,0,0,0,0,0,1.307211734,1.27862564 1,1.250259142,4.424155104,8.538444783,13.44671556,22.12730607,32.14530928,35.99902139,43.27794118,45.77115817,68.60251444,73.82494308,79.48487497,84.27763597,78.1171579, 80.2836099.82.06181111,84.06818386,83. 53432222,81.50204186 Afghanistan, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 , 0,0,0,0.112598381,0.865196277,2.498055472,4.826865367,9.833164022,17.71624331, 29.22037376,37.89493697,45.77817474,60.32631999,60.35299258    

this line while <(> Input = scan.nextLine ())! = Null to become the input Null . // string input = ""; // This line is an obsolete scan = new scanner (file); scan.nextLine (); while (scan.hasNextLine ()) {final string input = sca n.nextLine (); // Read the line after the check (string to make sure that one line is available) string [] countryname = input.split (","); // int a = integer Paraset (country name [ 1]); Println (countryNames [0]); //System.out.println(a);}

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -