Return-Path: Delivered-To: apmail-jakarta-struts-user-archive@apache.org Received: (qmail 24965 invoked from network); 9 Sep 2002 19:58:45 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 9 Sep 2002 19:58:45 -0000 Received: (qmail 2987 invoked by uid 97); 9 Sep 2002 19:59:06 -0000 Delivered-To: qmlist-jakarta-archive-struts-user@jakarta.apache.org Received: (qmail 2947 invoked by uid 97); 9 Sep 2002 19:59:06 -0000 Mailing-List: contact struts-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list struts-user@jakarta.apache.org Received: (qmail 2933 invoked by uid 98); 9 Sep 2002 19:59:05 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-Id: <5.1.1.6.2.20020909124916.00b27ee8@mail.harbornet.com> X-Sender: caraunltd@mail.harbornet.com X-Mailer: QUALCOMM Windows Eudora Version 5.1.1 Date: Mon, 09 Sep 2002 12:57:46 -0700 To: "Struts Users Mailing List" From: micael Subject: RE: Simple Question In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Just write a helper class that opens the file, loads it into a properties object, reads the properties, and closes the file. Something like the following: import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; public final class SilvaProperties { public SilvaProperties setProperty(String file, String key, String value) { key = Replace.replace(key, " ", ""); File hold = new File(file); Properties properties = new Properties(); try { FileInputStream input = new FileInputStream(hold); properties.load(input); properties.setProperty(key, value); FileOutputStream output= new FileOutputStream(hold); properties.store(output, " -- TRESBEAU -- "); output.close(); input.close(); } catch (FileNotFoundException fnfe) { } catch (IOException ioe) { } return this; } public String getProperty(String file, String key) { key = Replace.replace(key, " ", ""); File hold = new File(file); Properties properties = new Properties(); try { FileInputStream input = new FileInputStream(hold); properties.load(input); input.close(); } catch (FileNotFoundException fnfe) { } catch (IOException ioe) { } return properties.getProperty(key); } public Properties getProperties(String file) { Properties properties = new Properties(); File hold = new File(file); try { FileInputStream input = new FileInputStream(hold); properties.load(input); input.close(); } catch (FileNotFoundException fnfe) { } catch (IOException ioe) { } return properties; } public final class Replace { public synchronized static String replace(String content, String before, String after) { int position = content.indexOf(before); while (position > -1) { content = content.substring(0, position) + after + content.substring(position + before.length()); position = content.indexOf(before, position + after.length()); } return content; } } } } At 03:21 PM 9/9/2002 -0400, you wrote: >Are doing this within an Action? > > >James Mitchell >Software Engineer\Struts Evangelist >Struts-Atlanta, the "Open Minded Developer Network" >http://www.open-tools.org/struts-atlanta > > > > > > -----Original Message----- > > From: Mark Silva [mailto:msilva@authenex.com] > > Sent: Monday, September 09, 2002 3:07 PM > > To: Struts Users Mailing List > > Subject: Simple Question > > > > > > This is probably a simple question, but i cannot find the answer > > in any straighforward place. > > > > how do i get a property from my ApplicationResources.properties > > file within some java code. i know how to do this using a bean > > tag, but not otherwise. is there a helper class to do this? > > > > i am using this to assign default values for a form (within a > > form object). > > > > thanks, > > mark > > > > -- > > To unsubscribe, e-mail: > > > > For additional commands, e-mail: > > > > > > > >-- >To unsubscribe, e-mail: >For additional commands, e-mail: -- To unsubscribe, e-mail: For additional commands, e-mail: