|
 |
enterprise_java_beans thread: EJB Property File
Message #1 by "Franz Hoyer" <franz.hoyer@a...> on Sun, 17 Dec 2000 23:26:51 -0000
|
|
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C068D5.A7498F34
Content-Type: text/plain;
charset="iso-8859-1"
We use ini files ourselves, and here is an example program we use to read
data from a specified file. Hope this helps.
-----Original Message-----
From: Franz Hoyer [mailto:franz.hoyer@a...]
Sent: 17 December 2000 23:27
To: Enterprise Java Beans
Subject: EJB Property File
Hi,
does anybody has a good example how to read properties from a property
file. I use the weblogic server 5.1.0 and I would like to set some
Properties in a property file, which I can read during runtime.
thx
Franz
---
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS? Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development,
Web Development, Networking & Communications, and Hardware & Systems.
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
alistair.whittle@l...
leave-enterprise_java_beans-$subst('Recip.MemberIDChar')@p2p.wrox.com
------_=_NextPart_000_01C068D5.A7498F34
Content-Type: application/octet-stream;
name="GetParmValues.java"
Content-Disposition: attachment;
filename="GetParmValues.java"
/*-----------------------------------------------------------------*/
/* Class File : GetParmValues */
/* */
/* Function : Used to get values from a specific file */
/* */
/* Remarks : */
/* */
/* Amendment log */
/* */
/* Date ID CC No Description */
/* -------- --- ------ ------------------------------------------- */
/* 13/12/00 ACW - ---- Creation. */
/*-----------------------------------------------------------------*/
package Classfactory;
import javax.naming.*;
import java.util.*;
import java.io.*;
public class GetParmValues
{
public static String getValue(String parmName, String parmFileName)
{
// Posit value not specified
String parmValue = "";
// Get parameter value
try
{
// Create FileReader object using named ini file
String loc = parmFileName;
File ini = new File(loc);
FileReader iniReader = new FileReader(ini);
// Compile String from ini file
int charint = 0;
StringBuffer combined = new StringBuffer();
while ( charint != -1 )
{
charint = iniReader.read();
if ( charint != -1 )
{
combined.append((char)charint);
}
}
String iniString = new String(combined);
// Close File Reader
iniReader.close();
// Get the Property Value
int pos = iniString.indexOf(parmName);
if ( pos != -1 )
{
// Make sure "=" is next
int start = pos + parmName.length();
int end = start + 1;
String testeq = iniString.substring(start, end);
if ( testeq.equals("=") )
{
start = start + 1;
end = iniString.indexOf(";", start);
if ( end != -1)
{
parmValue = iniString.substring(start, end);
}
else
{
parmValue = "Error in INI File";
}
}
}
}
catch (FileNotFoundException e)
{
parmValue="FILE NOT FOUND";
}
catch (IOException e)
{
parmValue="IO EXCEPTION";
}
return parmValue;
}
}
------_=_NextPart_000_01C068D5.A7498F34
Content-Type: text/plain; charset="us-ascii"
Content-description: footer
---
NEED TECHNICAL TIPS, TOOLS, AND INSIGHTS? Is FREE okay?
Visit EarthWeb for the latest in IT Management, Software Development,
Web Development, Networking & Communications, and Hardware & Systems.
Click on http://www.earthweb.com for FREE articles, tutorials,
and discussions from the experts.
---
You are currently subscribed to enterprise_java_beans as: $subst('Recip.EmailAddr')
To unsubscribe send a blank email to leave-enterprise_java_beans-$subst('Recip.MemberIDChar')@p2p.wrox.com
------_=_NextPart_000_01C068D5.A7498F34--
|
|
 |