I want to replace "integer" with "int" in a file.Following is the code i have written,but its working.Pls let me know my mistake.
public static void declare(String[] array) throws IOException { // TODO Auto-generated method stub BufferedWriter b = new BufferedWriter(new FileWriter("F:\\test\\file.txt",true)); StringBuffer s = new StringBuffer(); String old="integer",newtxt,newt="int"; newtxt=old.replace(old, newt); for(int i=0;i<array.length;i++) { s.append(array[i]).append(" "); } b.write(s.toString()); b.write(newtxt); b.flush(); b.close(); }