Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   how to open and retrive text file(.txt)?? (http://www.go4expert.com/forums/retrive-text-file-txt-t4931/)

mochi2732 27Jun2007 10:51

how to open and retrive text file(.txt)??
 
Hello... i have a process where user want some data file(textfile.txt) from somewhere for example from D:\smart\445566.txt. After user have that file, user can choose whether he want save that file or display it as a text file. I have searched many times through web but didn't find any suitable example or solution.. :(
So..anyone here can give me some idea or code example about this problem???
~i'm using JSP..
~i really really need help here..
~thanks...

pradeep 27Jun2007 14:14

Re: how to open and retrive text file(.txt)??
 
Code: JSP

File inputFile = new File("C:\\test.java"); // put your filename here
   
BufferedReader br = new BufferedReader(new FileReader(inputFile));
   
System.out.println(br.readLine());
System.out.println(br.readLine());

response.setContentType("application/octect-stream");
response.setHeader("Content-Disposition","attachment; filename=" + "yourfile.txt" );


mochi2732 28Jun2007 07:50

Re: how to open and retrive text file(.txt)??
 
pradeep...
really thankful to your coding..
but i have question here..
could i used the same coding if the file is on the server?

pradeep 28Jun2007 10:13

Re: how to open and retrive text file(.txt)??
 
On a different server you mean?


All times are GMT +5.5. The time now is 16:15.