• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating dynamic ini file in java  RSS feed

 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm making an application in which I want to make .ini    file when I log in to the application the .ini should be capture and save in the temp folder  I had find ini4j library  but what will be the next step to create dynamic ini file either by using URL of the application.
 
Tim Moores
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is a "dynamic INI file", and what is the "URL of an application"?
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dynamic .ini means i want basically like if i m login to my software with my userid & password then it will create ini file with my name.ini  and if anyone else login with their id than the .ini file will be made by his or her name
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you have a web application that the user logs in to. Do you have a good reason you want to use ini files, and not just a user settings table in a database?
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's not a web application it's a desktop application and it has index.html that open the application in the browser so  I  need .ini file for human readable in it user id password everything will be created
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your application runs in a browser, it's a web application. You can't interact with the file system easily from a browser. You can interact with a file-system from your application's back-end, but that begs the question why you're not using a database instead.
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no in the index.html file we are only sending the link to open the browser
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java's equivalent to *.ini files are *.properties files, which you can read and write using class java.util.Properties.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then why is the URL significant in the creation of the INI file?
Niti Kapoor wrote:but what will be the next step to create dynamic ini file either by using URL of the application.
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Jesper you are right can you tell me how to capture each time .property or .ini file when the person is log in every time with their id and password the same name .ini file should be saved in the disk to view. Can you help please
 
Tim Moores
Saloon Keeper
Posts: 4036
94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's still not clear what you're trying to do. If you're developing this application, what stops you from creating whatever files you wish? A better approach might be to use the java.util.prefs API, which can store user-specific data in a platform-dependent, but user-transparent way. It's not a good idea to have files lying around that contain user credentials.

I'm also unclear what an index.html file, or an application URL, has to do with a desktop application, but that seems to have nothing to do with the problem at hand, so maybe it's not necessary to understand.
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just want to save .ini file  which is present in my URL of the application to the particular destination in the computer
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where do you get the URL from? Can you show us an example?
 
M Khalid
Ranch Hand
Posts: 57
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niti Kapoor wrote: I just want to save .ini file  which is present in my URL of the application to the particular destination in the computer


Here i am guessing that you are trying to store the "USER Parameters" embedded in the URL to a ".ini" or ".config" or ".properties" file on to a file location.
Is that correct Niti?
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are  right : wink:   M Khalid
 
M Khalid
Ranch Hand
Posts: 57
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
M Khalid wrote:
Niti Kapoor wrote: I just want to save .ini file  which is present in my URL of the application to the particular destination in the computer


Here i am guessing that you are trying to store the "USER Parameters" embedded in the URL to a ".ini" or ".config" or ".properties" file on to a file location.
Is that correct Niti?


So there are many ways you can achieve this use case.
1. If its java then you can use,  URLDecoder java.lang.URLDecoder and then using Properties java.lang.Properties class for saving and retrieving stuffs.
2. You can also use, URLCodec - from Apache Common Library for decoding with Preferences class java.lang.preferences and creating and saving .ini file.
2. If its Web Application there are different approaches based on the framework/languages you use.

You can use basic IO classes like InputStream,OutputStream, FileReader, FileWriter etc. for reading and writing the ".ini", ".properties", ".config" files.

Hope this answers you questions. If not then try to implement this and then share the code snippet so that someone can help you better on your queries.
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how are you going to access the URL in the first place?
 
M Khalid
Ranch Hand
Posts: 57
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i am guessing that somehow from desktop application a hyperlink or Web URL is being initiated along with the parameter and Niti Kapoor is trying to extract the details from that embedded URL and save it in some file location. (I am not sure about the actual use case here but from the above queries looks like that)
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked out ini4j?
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I had a check for ini4j   as I want in my application after page load test if url contains
&ini=
if it does, parse URL,
module=mm-pm-ini&noob=1&noshell=1&ini=niti&output_format=html

get Ini value and save contents in file c:/temp/niti.ini.  I think now it's very clear
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once again, can you explain to us how/from where your application will be getting the URL, before you can parse it?
 
Niti Kapoor
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, it is all in the database and I am getting the URL using webEngine.getLocation as this application is working as a web view in frame.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!