hi friends,
Thanx friends,let me make my requirement very clear, i am running through the file
until the exact book code is found, then i want to overwrite the bookName
public void modifyBookDetails(String str){
try{
String bookCode="B0000002";
String bookName= "MasteringJSP";
File f=new File("F:\\javapro\\BookMaster2.txt");
RandomAccessFile raf=new RandomAccessFile(f,"rw");
String line=raf.readLine();
while( line != null){
line=raf.readLine();
if (line != null){
String s=line.substring(0,8);
if (s.equals(bookCode)){
bookMas=bookCode+" "+bookName;
long filePos=raf.getFilePointer();// line here correct?
raf.seek((filePos);// line here correct?
raf.writeBytes(bookMas);
}
}
}
raf.close();
raf=null;
}
catch(Exception e3){
System.out.println("error in reading file"+e3.toString());
}
}
what I have in my Text File
BookCode BookName
B0000001 MasteringJava
B0000002 MasteringEJB
I want to overwrite B0000002 row such that now my text file will be
BookCode BookName
B0000001 MasteringJava
B0000002 MasteringJSP
I have used the above code what changes i have to do the code to meet my requierment
hi gay3 i could not reach to the link u gave to me becoz its saying its an invalid URL
Regards
Baskar