At 02:09 PM 4/13/2005, you wrote:
I have a file on my classpath that has a single string in it, no spaces, nothing else in the file.

I also have a bean defined in Spring which takes a string property.

What is the absolute easiest way to get this number out of the file, and passed as a String into my bean?

Every idea I have seems way too complex for this seemingly simple task.

Thanks,
Chad

P.S. For background info, the number is a version number maintained by AnthillPro, and the string property of the bean is displayed on the GUI as the version number.


Interesting question....I'd like to know the answer, too.

I suspect you already know that *if* the file was in Java Properties (i.e. key=value) format
that you could have Spring inject the value directly into your bean, as illustrated below
where I am assuming that the file 'AntHillPro.properties' contains a line like:
         anthillpro.version=5.6

Perhaps there is some similar way to just retrieve a single value. If so, I'd like to know, too.
         regards,
        -tom

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Runtime Property Configurator                               -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
      <list>
        <value>classpath:AntHillPro.properties</value>
        <value>classpath:db.properties</value>
      </list>
    </property>
  </bean>

.....
.....

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Business Object Beans                                       -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

  <bean id="versionReporter" parent="org.chad.project.BaseBusinessObject">
    <property name="version"><value>${anthillpro.version}</value></property>
  </bean>

Reply via email to