English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how should we create a simple text file in a web application.
i used
File file = new File("reports/one.txt");
to create a text file under the reports folder .This "reports" folder is along with the web-inf folder.
when i executed the servlet which had this code,its creating the file some where out side the application. i want that to create under the "reports" folder. how to achieve this. please help me.

2006-09-11 22:19:09 · 3 answers · asked by kanna 3 in Computers & Internet Programming & Design

hai joe young.
thanks for the link. i searched but i did not get it

2006-09-11 22:41:05 · update #1

3 answers

I bet it's creating the path/file relative to where the application (e.g. Tomcat) was started from, or from the user directory.

Use the ServletContext's getRealPath() method instead:
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

2006-09-15 18:01:38 · answer #1 · answered by vincentgl 5 · 0 0

Create Text File Java

2016-11-14 08:29:46 · answer #2 · answered by Anonymous · 0 0

kanna You will find your answer with this link

http://www.google.co.uk/search?hl=en&q=+text+file+in+a+java+web+application&btnG=Search&meta=

2006-09-11 22:22:32 · answer #3 · answered by Joe_Young 6 · 0 0

fedest.com, questions and answers