i have a text file with following enteries:
12345 2145 0912
4356 0981 2134
now i want to declare the vector according to the number of lines the text file is containing,i wrote the following code but it didn't work:
//scalable sequential
pattern mining
import java.io.*;
import java.util.*;
public class sspm
{
//static int numberofsequences;
//method for counting the number of sequences in the IBM data file
/*int count()
{
try
{
File f = new File("C:\\Program Files\\MyProjects\\final sspm\\sspm\\data1.txt");
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
LineNumberReader lnr = new LineNumberReader(br);
String line;
}
catch (IOException e)
{
e.printStackTrace();
}
return numberofsequences;
}*/
public static void main(String args[])
{
//Vector Transaction[] =new Vector();
//declaring array of transactions to hold individual transactions
//sspm s1=new sspm();
//int sequencesl=s1.count();
int numberofsequences=0;
try {
//vector for holding transactions
// files descriptors for accessing individual data files
File f = new File("C:\\Program Files\\MyProjects\\final sspm\\sspm\\data1.txt");
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);
LineNumberReader lnr = new LineNumberReader(br);
String line;
String temp[];
int spcount[] = new int[10];
//for counting the number of sequennces
while((line=br.readLine())!=null)
{
numberofsequences++;
}
//storing individual transactions in the array of vectors
System.out.println("total number of sequences in the data file are:"+numberofsequences);
File f1 = new File("C:\\Program Files\\MyProjects\\final sspm\\sspm\\data1.txt");
FileReader fr1 = new FileReader(f1);
BufferedReader br1 = new BufferedReader(fr1);
LineNumberReader lnr1 = new LineNumberReader(br1);
String line1;
Vector []transactions=new Vector[numberofsequences];
int index =0;
while((line1=br1.readLine())!=null &&index<=numberofsequences )
{
System.out.println(line1);
//numberofsequences--;
StringTokenizer st=new StringTokenizer(line1);
while (st.hasMoreElements( ))
{
String s1 = (String)st.nextElement();
transactions[index].add(s1);
//System.out.println("number of transactions in sequence "+ numberofsequences +" are "+ length);
//index++;
}
long length = transactions[index].size();
index++;
System.out.println("first vector size is"+length);
}
//System.out.println("total number of sequences in the data file are:"+numberofsequences);
} //end of try block
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e){
e.printStackTrace();
}
//System.out.println(Transaction.size());
//System.out.println(Transaction.size());
}
}