1. edit properties file coderanch.comRead 'em all in and write 'em all out is how the Properties class works. It's designed for use with small local files with values that change infrequently, so there's little inefficiency. If you really need random access you could try java.io.RandomAccessFile. Jules [ August 12, 2004: Message edited by: Julian Kennedy ] |
2. Read from properties file coderanch.comHi, I need to know how to read some values of certain keys from the properties file. this is possible when i tried to do in the Tomcat server but this was not possible when i tried out with the Jboss server. Why is this so?? please do help me out. public class SampleResource { public SampleResource() {} public String callResourcebundle() ... |
3. Read encrypted string from properties file coderanch.comI'm writing a password verification utility. I want to create a properties file with all users and their passwords in name/value pairs, such as user1=password1, where password is encrypted with 3DES. I added following entry in the properties file named "users.properties" tom=AAU but when I tried to retireve the encrypted password using following code, Properties users = new Properties(); users.load(new FileInputStream("c://users.properties")); ... |
4. Properties File? coderanch.comIm trying to use Properties for the first time and I am running into an error. Even when I cut and paste the example I get the same error. Here is the code. import java.util.Properties; Properties dbProperties = new Properties(); dbProperties.load(new FileInputStream("MyConnections.properties")); Error = Syntax error on token(s);misplaced constructor Sysntax error on load = expected after this token These are ... |
5. wt is Properties file coderanch.comProperties files are used in numerous places since they allow you to change text attributes without recompiling code. Anytime you see text labels on JSP pages or swing pages for example, such as the "Post A Replay" I see at the top of my page, its a good idea to extract those out to properties files rather than whats referred to ... |
6. When and How to use .properties file in JAVA program coderanch.com |
7. Properties file coderanch.comHi, I want to load a properties file. Below is the code that I have.I have synchronized at the method level?I know this will slow down the performance.How can I set the synchronization at the block level?Can anyone help me out? public synchronized Properties getPropertyFile(String fileName)throws Exception { Properties prop = (Properties) hashMap.get(fileName); if(prop == null){ prop = new Properties(); InputStream ... |
8. reading Arabic from a properties file coderanch.comHi, When reading Arabic out of a UTF-8 properties file, the Arabic gets garbled. I've seen some postings that indicate that one has to use the String.getBytes method to transform the garbled string into proper Arabic. Has anyone does this, and have a couple of working lines of code? I've played with it, but haven't gotten it to work. Maybe I'm ... |
9. properties file coderanch.com |
10. Properties File coderanch.com |
11. Annoying properties file coderanch.com |
12. Property files coderanch.comHi All, We are having some property files in our project. I don't want to do File I/O operation during each method call nor do I want to load the session with these values. So the property file loading was specified in the static block of the class and the values were retrieved. But the problem here is if the property ... |
13. Best place for .properties file? coderanch.comI have some classes packages in a .jar and put in the myApp\WEB-INF\lib folder of TomCat. These classes read a properties file which will be placed under a conf folder. Fo ex., they should read a file "\conf\db.properties" to get some info. When i created a 'conf' folder under the lib directory, the classes does'nt read from there. Should i package ... |
14. help me with specify properties file please coderanch.comhi, i actually want to use a relative path from my application root that is deployed into weblogic i.e. c:\bea\user_projects\scm\scm.war i mean a web application packaged in war file should have WEB-INF (dir) web.xml and my application.properties is in WEB-INF/classes/config/application.properties how can i reference to the application-root not the os root. can u help! danny. |
15. Where Do I Place The Properties File? coderanch.comI am trying to leave out the information, such as driver, url, username, password from the class that gets a connection from a connection pool. I store those information in the dbConnectionProperties.prop file. Am I supposed to put this properties file at the application root? Is the application root the same as the root of the ServletContext? In terms of Tomcat, ... |
16. .properties file coderanch.comhi, i use a .properties file to load the database preferences into an object which connects to db. the object is used by a servlet, and therefor is found in $CATALINA_HOME/webapps/XYZ/WEB-INF/classes/ folder. the .properties file should be stored in classpath, but on winxp machine nothing but putting it in the same .../classes folder works for me. the problem is that .../classes ... |
17. relative path for .properties file .. pls help coderanch.com |
18. problem with path for properties file coderanch.com |
19. Writing properties to same properties file . coderanch.comAfter looking at your example and my code that was attempting to save the properties, I am exactly doing what you proposed. I say: (with the filePath being "/db.properties") public static void writePropertiesToFile(String filePath,Properties propertiesToSave) throws IOException { File f = new File(filePath); System.out.println("path:" + f.getAbsolutePath()); FileOutputStream writer = new FileOutputStream( filePath ); // Writing the system properties to the suncertify.properties ... |
20. Writing to properties file in WEB-INF coderanch.com |
21. property files coderanch.com |
22. how to access properties file coderanch.comHi I need to use a properties file to replace variables in a Java program and a servlet. Eg. of Java program: **************************************************** public class SendResponseThread implements Runnable { Thread responseThread; String dirName; File destFolder; boolean dirCreated = false; private final static SimpleDateFormat dateFormatForFileName = new SimpleDateFormat("yyyyMMdd-HHmmss-SSS"); Date now = new Date(); SendResponseThread() { /* dirName = "c:\\Transmission"; destFolder = new ... |
23. properties file coderanch.com |
24. about properties file coderanch.comSiva, Ben meant the "F" as in the last letter of .jspf, or fragment. Normally, when you have a standalone JSP, you can type its name into a web browser and get some output. A JSP fragment is intended to be part of a JSP. So if you were to type its name into a web browser, you wouldn't expect to ... |
25. where to place .properties file coderanch.com |
26. how to .properties file coderanch.com |
27. Property files coderanch.comMy question is more related to Web Applications. I want to store some properties in a property file. To read this file I need to provide the path to the file holding the properties. My question is: 1) what are options in order to provide this path. I can myself think of two ways a) Hard code the path in my ... |
28. how container can access .properties file on the basis of client specific language coderanch.comhi If i have clients from different geographical regions(for ex french, japanese) then my application will have MyApplication_french.properties, MyApplication_japanese.properties files when a french/japanese client access the welcome/index page there he can select the language in select box and clicks on the submit button based on this language parameter a particular application.properties is selected 1) how this process goes on and 2) ... |
29. use of properties file coderanch.comI need to connect to a database I have specified the driver class and url in a .properties file, I have placed this .properties file in the classes folder of WEB-INF once I create the war file and sent it to the client, They need to change the url but since we are delivering a war file they cannot do it. ... |
30. use of properties file coderanch.comI need to connect to a database I have specified the driver class and url in a .properties file, I have placed this .properties file in the classes folder of WEB-INF once I create the war file and sent it to the client, They need to change the url but since we are delivering a war file they cannot do it. ... |
31. Problem while using properties file coderanch.com |
32. How to read properties files from outside Container? coderanch.comHi Web Container Gurus! Ive got a servlet from which I want to load properties/config files. Today these files are located in WEB-INF/classes, but I want to relocate them to a location within the same server that is outside this specific web app or Tomcat installation. My thought is to refer to these files using the File object. Is this possible, ... |
33. Can i place localization properties file otherthan WEB-INF/classes coderanch.comI am working on localization for 2 languaes en and fr. my web.xml contains following |
34. Properties Files coderanch.comProperties (and property files) are a feature of Java in general; they have nothing in particular to do with servlets or JSP. They are often used for keeping system settings and preferences in files that can be maintained outside of the code. Some 3rd party libraries (e.g. log4j and Hibernate) make extensive use of them for their own configuration. It's more ... |
35. accessing a .properties file coderanch.comFirstly, if you get a reference to the System properties and update them, then the System properties should be updated. You shouldn't need to write them back. Starting from first principles though, should you be doing this via a properties file, or should you be setting the System properties on the command line using the JVM -D arguments? Thirdly, you could ... |
36. Properties files - directory structure coderanch.comIs there some convention for what directory to place custom properties files in? I want to write a utility API and include it as a JAR. The servlet context will get me access to the "web" directory, and I usually put the files in /WEB-INF, but helper classes that don't have access to the servlet context seem to only be able ... |
37. How to access properties file from WEB-INF/ directory coderanch.com |
38. Property Files coderanch.comI have a properties file where I'd like to have more than one word on the left side of the property (with spaces in between the words). For example: test one = Test1 test two = Test2 I don't see how you can have a space on the left side. I always just get "test". Do I need to override this ... |
39. Run Into Problem When Move Hard Coding to a properties File coderanch.comprivate final String PROPFILE = "resources/smtpServer.properties"; private Properties oProp = null; public SendBatchMails() // this is the constructor in my class { try { oProp = new Properties(); oProp.load ( getClass().getClassLoader().getResourceAsStream( PROPFILE ) ); } catch( IOException oEx ) { System.out.println("Unable to load the Properties " + PROPFILE + oEx ); } } ...... String smtpServer = oProp.getProperty( "smtpServer" ); Properties ... |
40. reading properties file coderanch.comIam currently using jdk1.4. I have a to read a properties file containing text, key = value spaced key = spaced value Can I set the delimiter that is to be used by Properties, in this case I would want only '=' as the delimiter and ignore whilte space between the keys. Is there any way that I can acheive this ... |
41. Merging Property files coderanch.comI have a requirement to merge two property files with features below 1.Maintain order of attributes i.e., order of keys should not be disturbed after merge 2. Comments should be retained. is there any standard utility api for the above requirement OR any suggestions ? Thanks, ------------ [ August 08, 2005: Message edited by: Prasanna Kumar BP ] |
42. integer from properties file coderanch.comCheck out java.util.Properties.load(). Its a general method to read properties files from an InputStream and load them into a Properties object set. Depending on where the data is coming from (the user, server, specific file location, etc) your code to read the file as and send it to a stream will vary. |
43. Tutorial on using java .properties file coderanch.comCan anyone post a good link on how to set up and use a ,properties file. I have a webservice which at the moment has hard coded values. I want to put those values in a properties file so that if any of the values change I do not need to regenerate and load the EAR file. Also is a properties ... |
44. adding a properties file coderanch.comIn my new job one of the exercise they gave me was to put all the hard coded values in to a properties file. Code is pure java but I do the development in websphere just use as a IDE. I created a text file with all the hard coded values. Can someone tell me how to get them to the ... |
45. Hardcoding a properties file coderanch.comThis may be extremely trivial, but I was wondering, is it considered "bad style" to hardcode the name of a .properties file into an application. I created the .properties file so that I didn't have to pass a bunch of command line arguments at startup, but then I started thinking, well what if I want to change the properties, I would ... |
46. Default Language Properties file coderanch.comHi, My scenario is, I have 2 or more language properties files for different langauges. My problem is, if the specified key element is not there in the corresponding properties file, it has to take the corresponding key value from English properties file. Is there any way to do so? Thanks in advance, Prasad. |
47. properties file coderanch.comHello there, I was tring to create a properties file for my applications. But I could not figure out where to keep it. I mean I am using eclipse for development so I was wondering whether I could create a props file in workspace or is there any there place for it. And if at all if we keep in the ... |
48. When and How to use .properties file in JAVA program coderanch.com |
49. what is a properties file? coderanch.com |
50. Reading Property Files coderanch.comHi everyone !! got another query here, i have this property file, "ducatProperties.properties" with simple content like: message=How are you RAVISSANT MARKENDAY Now i want this properties file to be read by a servlet in the same location("classes" directory), DURING INITIALIZATION. So i write the following code: public void init() { String message; Properties props = new Properties(); try { props.load(new ... |
51. How Can I read a .properties file coderanch.com |
52. Problem regarding saving properties file coderanch.com |
53. Reading properties file problem coderanch.comDear All, I'm up against one of those irritating classpath problems. Let me explain the scenario: I have an application deployed as a jar file. This application reads a properties file when it fires up. This properties file needs to be placed in a different directory when deployed so that the administrator can edit the properties contained within it. I have ... |
54. multiline properties in property file? coderanch.comin a property file, i think it is legal to use '\' for line continuation, but i have not found any documentation on it. i'd like to have a multiline property containing html, not sure if it is legal. where can i find further information on it? Is what i am showing below ok? Are there certain characters that are restricted ... |
55. reading properties file coderanch.com |
56. reading properties file coderanch.com |
57. Working with properties file coderanch.comHi all, I have to work with properties file and wonder how I can get hashmap of the keys ? I have properties like : FileTransformer. |
58. properties file, default location coderanch.comJust a quicky... When creating a webapp folder structure (web, WEB-INF, META-INF, class, lib, etc) is there a default location for property files? Looking at a DB Conn Pool and the values of the DB (user, pwd, driver, etc) are in a property file, and the line that calls the file is: InputStream is = getClass().getResourceAsStream("/dbconn.properties") Is there a default location ... |
59. Finding properties files coderanch.comI'm not sure if this is the right forum, but here is what I'm trying (and failing) to do: I'm using the Spring framework in a Java application. I need to load the application context and a properties file, but I cannot find the files when I run the app. I have tried using the FileSystemResource("filename"), but it never finds the ... |
60. Uploading file path in properties file coderanch.comI am using the below code to upload file and works fine. I am saivng the files at C:/upload/images which is declared in the above code. How can I put this path(C:/upload/images ) in the properties file, so that any change in destionation can be changed directly in propertied file ony. Any suggestions String saveFile = ""; String contentType = request.getContentType(); ... |
61. Reading from two property files using a relative path coderanch.comHi all, I have two property files having key value pairs. While the names of the keys are the same, the values of these keys are different in these files. viz. file1.properties ------------------ xsl_file_path=file:///C:/Documents and Settings/Desktop/My_workspace/MyAppWeb/webApplication/xsl/modify.xsl file2.properties ------------------ xsl_file_path=file:///apps/softcopies/WebSphere/AppServer/installedApps/SomeNetwork/MyApp.ear/MyAppWeb.war/xsl/modify.xsl I want to have a single properties file and i want to access the key and value pair using relative paths. Please ... |
62. Updating Properties file coderanch.comGuys, Need your help on the below. Have a simple application that allows the user to register on the website. Have a properties file that i need to store the username & password with which the user would register. The code is as below :- --------------------------------------- Properties properties.put(userId, userPassword); String fileName = this.getClass().getClassLoader().getResource("resources/registeredUser.properties").getFile(); FileOutputStream op = new FileOutputStream(fileName); properties.store(op, null); op.flush(); ... |
63. Accessing the Properties File coderanch.com |
64. How to use Properties file contents coderanch.comHi, I had been using the properties file in JSP, JSF it works fine. I want to implement the same here in the java code. Here i am using a web application where the property file is placed inside a package. I have some details like File Name, File Path, etc.. So, if i try to refer the file with "abc.properties". ... |
65. Alternative to properties file coderanch.comHi, I am creating one application in which i dont want to use normal properties file for storing the configuration. I want to put all my configuration in database and provide an API for fetching the configuration.. Can any one give me some path forward. How should i design my database and API.. Thanks, Saumil |
66. How to read properties file? coderanch.comThere are many ways to read properties file in java. Here explained two way, using 1. ResourceBundle 2. Properties Class How to use this tutorial 1. Create one directory src and put both below files (MyProp.properties and ReadPropFile.java) 2. MyProp.properties name = Binod Kumar Suman roll = 110 city = Bangalore 3. ReadPropFile.java import java.io.FileInputStream; import java.io.IOException; import java.util.Enumeration; import java.util.Properties; ... |
67. Multi-dimensional properties file coderanch.comWhat I have is a table that uses a key to get multiple fields related to that key, for example, use 'name' to get the other fields (address, phone number, etc.). The values in the table change rarely, and there are very few entries. Maybe the properties file isn't the way to go? |
68. Arguments to Properties File coderanch.comHello Friends, I have one requirement with resources or properties file I have one properties file, with key value pairs like this error.productid.activation=your {0} is not yet activated. error.productid.campaignid.disable=your {0} and {1} is not enabled. I have to pass values dynamically to this key while fetching value. How to pass and how to do this in java program. |
69. arguments to a properties file coderanch.comI have a mail.properties file, to which I should pass the name as an argument... the properties file looks similar to this message = hi ${0} , This is a test mail. the name is dynamic and is passed when the properties file is loaded. I'm loading it using ResourceBundle. I'm unsure how to pass the name as the argument and ... |
70. Problem in replacing key/value pair in properties file coderanch.comHi Friends, My Problem is : If i replace any value for corresponding key, its replaces fine and the same way , its remove all (#)comment files. How Can i resolve this problem: for Example: The Existing Properties file contains: # comment 1 one = 1 # comment 2 two = 2 After Replacing the key of one #comment 1 # ... |
71. Modifying Property Files. coderanch.comYes you can use the Properties class to load and store a property file. look at the load and store methods of this class. The properties class is basically a Hashtable and you can put and remove elements from it. The only problem might be that you will lose any comments already in the property file. I believe the Jakarta Commons ... |
72. Frameworks for reloadable properties file coderanch.com |
73. Property Files (placement of the file in the environment) coderanch.comProperties are treated as files, and so are discovered relative to the CODEBASE, i,e., wherever in the file system the executing class is. What I usually do is bundle all my classes into a JAR file, and then put the properties file wherever I care to in the directory structure of the jar. You can also use the -jar option for ... |
74. Properties Files coderanch.comAfter many months away I am starting to get back to my Java project, which means I am relearning may things I thought I understood... I have a program that performs a JDBC connection but I don't want to hardcode the IP address or Database drivers, I would like to be able to store several and simply 'activate' the one I'm ... |
75. properties files, initial directory, etc... coderanch.comHello Everyone! I am having a fair bit of trouble with properties files, namely how to ensure that they are in the same location on various platforms without recompiling. I develop in Windows at work, and on Linux at home, and every time I transfer code, I have to edit my classes and recompile so they have the proper path... example: ... |
76. Properties file coderanch.comDear, I have properties file that i have to set with new value. But after i set with new value, the size of that properties size is 0kb... This is the codes: import java.util.*; import java.io.*; public class TestUtil { public static void main( String[] args ) { TestUtil a = new TestUtil(); a.setScheduleProperties( "ThreadUserCancel" ); } public synchronized void setScheduleProperties( ... |
77. Where java.properties file is kept coderanch.comI don't intend to alter system properties like os.name, etc. You know how you can specify you java.policy file to setup your security policy? I thought you could do the same with a properties file so that instead of always doing: java -DMyCustomSysProperty=myValue I could just set it once in a file and forget it. Maybe I'm just imagining the whole ... |
78. property files (Why does java make this so hard?) coderanch.com |
79. properties file coderanch.comThere are several ways to do this. You could take the name and location of the file as a command line option, or (especially if it isn't your top level class) you could make the name of the file an attribute of the instance of your class. You could also specify the name of a settings file that you will read ... |
80. Questions about properties files coderanch.comHello, I have two questions about properties files. 1. Is it possible to import a properties file from another properties file? 2. Is it possible to have variables in a properties file as described below in code snippet. Thanks in advance, Julien. Code snippet: var_one=foo var_two=$var_one bar The second line would then read "foo bar" |
81. properties file editing coderanch.comHi Paul, tried using the following code: FileInputStream fin = new FileInputStream("foldername.properties"); FileOutputStream fout = new FileOutputStream("foldername.properties"); Properties props = new Properties(); props.load(fin); props.remove("test"); props.store(fout, "removed test"); inside the properties there are a few keys and "test" is one of them, if I set fout to true, it will append the whole properties file below without the removed key. But if ... |
82. Reading properties file problem coderanch.comDear All, I'm up against one of those irritating classpath problems. Let me explain the scenario: I have an application deployed as a jar file. This application reads a properties file when it fires up. This properties file needs to be placed in a different directory when deployed so that the administrator can edit the properties contained within it. I have ... |
83. Properties File reading coderanch.comDear Ranchers, I'm doing a project in JSP and MySQL. For the JSP-MySQL connection , I'm now writing the connection statments in each and every time when I want to insert,delete, update of select the database queries. If I change the MySQL root password, it will affect the coding completely.. So Instead of that I want to put properties file to ... |
84. Reading key/value pairs from a .properties file and creating objects coderanch.comHi all I am trying to read from a .properties file which has key value pairs for Employee's id, first name, last name and age. I tried to use the Property class's .keys()method into an iterator and construct Employee objects. But the keys were stored in a different order than the one which I stored. I have used the keySet() and ... |
85. system variables in .properties file coderanch.comHi Balasubramanian Chandrasekaran: already i worked with all these. what i want is: - i will store my .properties file in user.home - this above .properties file should have entries to refer system variable's values like: videofolder=%user.home%\video\; audiofolder=%user.dir%\audio\; - ie from my own .properties file i want to access/refer system variables - How can i do this, syntax, sample, please!! Thanks ... |
86. getting Properties file in MessageBundle coderanch.comThe getBundle() method will look for the desired resource bundle on the classpath. In this case, since the locale you are passing in is "en_US", and you are using "MessageBundle" for the baseName, it searches the classpath for the file "MessageBundle_en_US.properties". If it can't find that file, it will look for a file name "MessageBundle_en.properties". Finally, if it can't find that ... |
87. Properties file coderanch.com |
88. Variables/properties used in property files coderanch.com |
89. properties file not found coderanch.com |
90. Problem with properties file coderanch.comThat's going to be hard, and I doubt it can be done automatically. You first would have to find all Properties objects that load from that properties file (already quite hard - sometimes the properties file can be relative, otherwise absolute). Then you have to find all calls to getProperty on those objects and retrieve the property name from those calls. ... |
91. Replace words in a file by reading a properties file coderanch.comhi guys, am working on file which contains the following many lines of data, Message, String1, String2, String3, String4 Now string1, string2, string3, string4 are alphanumeric codes. now i need to read a properties text file which contains the strings associated with these codes. eg. "String1"="Test Message" so i need to parse my file and replace all occurences of codes with ... |
92. Reading properties file coderanch.comHi, I am setting up very basic web application. the application consists of 2 small applications. 1: web app 2: common app The db related things are being done in common-app (connection, queries, etc - direct JDBC). and this common app is being added to the web app through JAR integration (using eclipse 3.3 include project). I want to keep my ... |
93. Properties file issue coderanch.comHi, Yes, I am using the following method to write into properties file.Properties props = new Properties(); FileOutputStream fo = null; try { fo = new FileOutputStream("Filename.properties"); //localdest properties file(each time from jsp properties are saved in this file and then this file is passes to the remote server) props.store(fo, "Filename.properties"); but as we know we can't retain comments.To save comments ... |
94. Different approach to Properties file ? coderanch.comHi , I have a standalone java application which is run by scheduled job. In the application , i have to check for country specific attributes to control the flow of statement. Usually i would create a country specific properties file and load the property file at the start and continue the action. Basically what i have in property file is ... |
95. Placeholders in property files coderanch.comPlease could you tell me if a class exists that can take two property files and merge them together using Ant build script style placeholders? E.g.: Dynamic property file: item1.path={environment.start.path}\{location}\item1 item2.path={environment.start.path}\{location}\item2 Placeholder values property file: environment.start.path=MyDevServer location=uk After the placeholders have been expanded, item1.path would be: MyDevServer\uk\item1 item2.path would be: MyDevServer\uk\item2 Thanks |
96. Retrieve owner property from file or directory coderanch.comHow is this question related to JSP? Incorrectly writing raw Java code in a JSP file instead of a Java class, and having problems with that Java code doesn't make it a JSP problem. The IO forum would have been more appropriate. Have patience and a moderator may move it sooner or later. |
97. Can't locate properties file coderanch.compackage org.apache.xmlrpc.demo.webserver; import java.net.InetAddress; import org.apache.xmlrpc.common.TypeConverterFactoryImpl; import org.apache.xmlrpc.demo.webserver.proxy.impls.AdderImpl; import org.apache.xmlrpc.server.PropertyHandlerMapping; import org.apache.xmlrpc.server.XmlRpcServer; import org.apache.xmlrpc.server.XmlRpcServerConfigImpl; import org.apache.xmlrpc.webserver.WebServer; public class Server { private static final int port = 8080; public static void main(String[] args) throws Exception { WebServer webServer = new WebServer(port); XmlRpcServer xmlRpcServer = webServer.getXmlRpcServer(); PropertyHandlerMapping phm = new PropertyHandlerMapping(); /* Load handler definitions from a property file. * The property file ... |
98. Reading properties from another properties file. coderanch.com |
99. FileNotFoundException When Trying to Read from a .properties file coderanch.comDear Sirs and Madames, I am trying to read from a properties file message.properties which is in the SAME package as the calling class. However I keep getting the rintime error message java.io.FileNotFoundException: message.properties (The system cannot find the file specified). I have racked my head as to why this could be but to no avail, for the dake of my ... |
100. Properties file coderanch.com |