We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,695 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Cannot delete after editing .properties file

This is my jsp code for saving back the data to .properties file after editing. i used 2 Linked properties as one LinkedProperties pro is to get the data from the path and the other one to get attribute (eg: id, name, age, gender etc.) from default .properties file so that i don't have to hard code everything in every page:

String path = request.getParameter("path");
	System.out.println(path);
	File dir = new File(path);
	FileInputStream in = new FileInputStream(dir);
	LinkedProperties pro = new LinkedProperties();
	pro.load(in);
	Enumeration em = pro.keys();
			
	//default file
	File d_dir = new File("C:/workspace_indigo/Configuration/WebContent/default.properties");
	LinkedProperties d_pro = new LinkedProperties();
	FileInputStream d_in = new FileInputStream(d_dir);
	d_pro.load(d_in);
	Enumeration ems = d_pro.keys();
			
	//save to file.
			if (request.getParameter("id") != null) {
				while (ems.hasMoreElements()){
					String str = (String) ems.nextElement();
					pro.setProperty(str, request.getParameter(str));	
				}
				pro.store(new FileOutputStream(path), null);%>
				
			<script type="text/javascript">
				alert("Change Saved sucessfully.");
				//window.location.href="List_of_Repo.jsp";
			</script>
				
		<% 	}
			d_pro.clear();
			d_in.close();
                        pro.clear();
		        in.close();

I can save the file back into the corresponding .properties file but the problem is i cannot delete the file after editing is save. The error message is the file is still in used.

help me.

2
Contributors
2
Replies
2 Days
Discussion Span
1 Year Ago
Last Updated
3
Views
kyraa
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

this discussion board is so not helping... :(

kyraa
Newbie Poster
3 posts since Nov 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

Did you ever considered that is not 24/7 coding solution, or that perhaps people do not want to do anything with coders that insist to do stuff directly from JSP or perhaps people do not know or are not interested.
Count me in the group "do not want to touch code with direct JSP manipulation". Word of advice, it is possible, I do use it often when I change CSS settings of my blog that is run on open source project called Pebble. There is your solution, go through code and find you solution there...

peter_budo
Code tags enforcer
Moderator
15,787 posts since Dec 2004
Reputation Points: 2,867
Solved Threads: 944
Skill Endorsements: 49

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0631 seconds using 2.69MB