Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   Is it possible to find and Replace a string inside a textfile using JSP? (http://www.go4expert.com/forums/replace-string-inside-textfile-using-jsp-t23245/)

alexantony 8Sep2010 13:00

Is it possible to find and Replace a string inside a textfile using JSP?
 
Code:

FileInputStream fs = new FileInputStream("/opt/Abhishek/software/tomcat/webapps/AMS/listpass");
DataInputStream in1 = new DataInputStream(fs);
while (in1.available() !=0)
{
String str1=in1.readLine();
StringTokenizer st1 = new StringTokenizer(str1);
String node=st1.nextToken();
if (node.equals(sports[i]))
{
String pass=st1.nextToken();
out.println ("<b>"+sports[i]+" <b>");
out.println("**Your Required Password**");
out.println(pass);
out.println("<br></br>");

Hi ,
I have a text file (named listpass in the above code) inside tomcat-webapps folder containing a node name and its password.You could see the path of the text file at the starting line of the code.The Scene behind the program is once the particular node is clicked the password is retreived for the user against the particular node.What i would need is to change the password in the text file once it is retreived. So i would need to find the password that is retreived recently and change that one with a randomnly generated new password in the text file.

So can i do this?Is it possible to search for the string in the text file and replace that with a new one using JSP.For your note i am running all my HTML amd JSP inside the same folder where i have the text file in which the string has to be replaced .

Could anyone give your comments on this please?


All times are GMT +5.5. The time now is 20:58.