So what I want to do is something like this: Assume I have a File object that is linked to a physical file in the system. I want to modify it a few times before writing the content back to a new file. How can I do this? So here is the sample code:
File x = new File("somefile.txt");
// Ask user to enter a String
Scanner s = new Scanner(x);
while(s.hasNextLine())
String nextLine = s.nextLine();
if(userString.equals(nextLine))
nextLine = nextLine.toUpperCase();
Now at this point, I do not want to modify the file x itself. I also do not want to write a physical file. I just want a representation of the same file, in same order, but some lines in uppercase, so I can loop through the same lines again.
What I want do is I want to to be able to loop through the same (but modified) file again.
How can I do this?