problem reading&writing word documents
hi:
i wrote a program to look for a string and replace it with another. reading and wirting are done in the same file. it works fine as long as the file is a text document. if any one has any suggestion on how to make this program work for any file i would appreciate it. here is a portion of the codes that does the reading and wiriting. thanx.
f =new RandomAccessFile(aFile, mode);
int fLength = (int)f.length();
int bytesRead;
byte[] b;// = new byte[fLength];
String toWrite ="blood suckers";
String s;
try{
b =newbyte[fLength];
while (f.read() != -1)
f.read(b);
s =new String(b);
System.out.println(s);
long p =(long)s.indexOf(pattern);
String string1 = s.substring((int)p, (int)p+patternLength);
System.out.println(string1);
String string3 = s.substring((int)p+patternLength);
System.out.println(string3);
toWrite += string3;
byte[] aByte = toWrite.getBytes();
f.seek(p+1);
f.write(aByte);

