1,105,409 Community Members

Cannot delete after editing .properties file

Member Avatar
kyraa
Newbie Poster
3 posts since Nov 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
kyraa
Newbie Poster
3 posts since Nov 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
peter_budo
Code tags enforcer
7,934 posts since Dec 2004
Reputation Points: 2,502 [?]
Q&As Helped to Solve: 1,028 [?]
Skill Endorsements: 66 [?]
Moderator
Featured
 
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...

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: