In order to index my collection of tweets I have written this code but an error appears I do not know is what I should initialize a few things, thank you.
public static void main (String args []) throws IOException{
String line;
Gson gson = new GsonBuilder().create();
File f = new File(Constante.DATA);
BufferedReader reader;
Indexer indexer = new Indexer(Constante.INDEX);
int nbrtweet =0, i=0;
for(File file : f.listFiles())
{
System.out.println(file.getName());
reader = new BufferedReader( new FileReader(file));
while((line = reader.readLine())!=null){
Tweet tweet;
try{
tweet = gson.fromJson(line, Tweet.class);
}catch( JsonSyntaxException e){
i++;
continue;
}
nbrtweet++;
indexer.indexTweet(tweet);
}
The error shows up on this line:
for(File file : f.listFiles())
and prints
Exception in thread "main" java.lang.NullPointerException
at ApprocheTwitter.src.Indexer.IndexationThematiqueTwits.main(IndexationThematiqueTwits.java:26)