Hi all,
I am trying to read a txt file shown below
PRODUCT INFORMATION FORM
Title of application: Selling Tips
Number of products: 2
Product Name: TissueMend
Photo: tm.jpg
Description: TissueMend(r) is a strong, suturable, porous collagen biomembrane that is derived from fetal bovine dermis.
Indications: Generally indicated for surgical procedures to reinforce and repair soft tissue where weakness exists.
Number of Competitors: 1
Competitor Name: Zimmer
Competitor Description: They have bones.
I have the following questions
1. Is there some way to find the end of file is reached.
2. Also any insight, if its is possible to read a Ms-Word directly or save it to txt file
3. The curent code which is as follows throws a null pointer exception whenever bufferedReader.readLine() reads null.
System.out.println(".........Inside readMyFile");
BufferedReader br = null;
String line = null;
String num_Of_Products = null;
StringBuffer buf = null;
boolean cond = true;
try {
br = new BufferedReader(new FileReader(path));
do{
line = br.readLine();
System.out.println(line);
if(line.length()==0)
System.out.println("line is null");
counter++;
if(counter >4)
cond=false;
buf.append(line);
}while(cond);
}
catch(FileNotFoundException fnfe){
fnfe.printStackTrace();
}
catch (IOException e) {
System.out.println("ioexception" + e.getMessage());
e.printStackTrace();
}
finally {
if (br !=null) {
try {
br.close();
}
catch (IOException ioe) {
}
}
}
return buf.toString();
}