Reading a file and change the content with vector


import java.util.*;// Arrays.sort
public class Test_This {
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
Process p1 = new Process();
InputStreamReader isr = new InputStreamReader(;
BufferedReader br = new BufferedReader(isr);
String file_name ="";
Process pp = new Process();
System.out.print("Please Enter a File name: ");
file_name = br.readLine();
catch(NumberFormatException e)
{ System.out.println("data was blank");}

class Process
//vector is stretchable
public Process(){System.out.println("Default) constructor");}
public void method_1(String str)throws IOException
String file_name="", line;
//ArrayList buff = new ArrayList();
Vector buff = new Vector();
int index = 0, index2=0;
BufferedReader Source = new BufferedReader( new FileReader( str));
try {
//for (int i =0; i <buff.length; i++)
while ((line = Source.readLine()) != null)
} catch (IOException e) { System.out.println("could not read at process"); }
finally{ Source.close(); System.out.println("Soruce closed"); }
Iterator it = buff.iterator();
System.out.println("---Iteratring Array List----");

System.out.println(index++ + "\t" +;

System.out.println("--replaced a line with---");
buff.set(8, " Welcome to Java Vector");
Iterator it_2 = buff.iterator();
System.out.println(index2++ + "\t" +;


Since Vector or ArrayList create an Internal Index that can be used to edited with vector.set

Note the line was replaced with welcome to java.