package mp1similar;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import EarthquakeRecord.Earthquakerecd;
public class MP1Similar
{
private static ArrayList arrayList ;
public static void main(String[] args)
{
ArrayList arrayList= null;
try
{
BufferedReader br = new BufferedReader(new FileReader("data/Catalog.txt"));
String line="";
arrayList =new ArrayList();
while((line = br.readLine())!=null)
{
// System.out.println(line);
StringTokenizer st = new StringTokenizer(line);
while(st.hasMoreTokens())
{
//System.out.println(st.nextToken());
arrayList.add(st.nextToken());
//System.out.println(br.readLine());
}
}
}
catch (FileNotFoundException ex)
{
System.out.println(ex.getMessage());
ex.printStackTrace();
}
catch (IOException ex)
{
System.out.println(ex.getMessage());
ex.printStackTrace();
}
int j=0;
Earthquakerecd E[]= new Earthquakerecd[2000];
for(int i=0;i< arrayList.size();i++)
{
System.out.println(arrayList.get(i));
E[j] = new Earthquakerecd();
E[j].setDate(arrayList.get(i));
if (j>35 )
{
j=0;
}
j++;
}
}
}
I am getting an error in the line E[j].setDate(arrayList.get(i)); It says that the actual argument cannot be converted to java.lang.String by method invocation.
All the fields in the object are String Types. The arrayList contains all the data extracted from the TXT file. I am trying to transfer all the data from the arrayList to the object array. The txt file has 35 columns and 1500 rows. The data being seperated by whitespace
Change:
to:
or just: