<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: properties code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 00:39:29 GMT</pubDate>
    <description>DZone Snippets: properties code</description>
    <item>
      <title>Copy all svn:* properties from one file to another</title>
      <link>http://snippets.dzone.com/posts/show/5501</link>
      <description>The following script can be used to copy all SVN properties from one file (presumably a file that's already under SVN control) to another file (which you presumably want to put under SVN control, and which you want to check in with the same SVN properties).&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;ORIG=$1 ; shift ;&lt;br /&gt;[ -e "$ORIG" ] || exit ;&lt;br /&gt;&lt;br /&gt;for PROP in `svn pl "$ORIG" | sed -n '2,$p'` ; do&lt;br /&gt;        VALUE=`svn pg $PROP "$ORIG"` ;&lt;br /&gt;        for FILE ; do&lt;br /&gt;                [ -e "$FILE" ] &amp;&amp; svn ps $PROP "$VALUE" "$FILE" ;&lt;br /&gt;        done&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;# That's it, Folks!&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;If you put the above code in a shell script called...&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;svnprops.sh&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;... then you can run it as follows if you want to copy all svn:* properties FROM original.file TO blegga:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pvdb@localhost ~ $ ./svnprops.sh original.file blegga &lt;br /&gt;property 'svn:mime-type' set on 'blegga'&lt;br /&gt;property 'svn:eol-style' set on 'blegga'&lt;br /&gt;pvdb@localhost ~ $ _&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;... or as follows for multiple target files:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;pvdb@localhost ~ $ ./svnprops.sh another.original.file blegga foo bar &lt;br /&gt;property 'svn:mime-type' set on 'blegga'&lt;br /&gt;property 'svn:mime-type' set on 'foo'&lt;br /&gt;property 'svn:mime-type' set on 'bar'&lt;br /&gt;pvdb@localhost ~ $ _ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;</description>
      <pubDate>Fri, 16 May 2008 11:25:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5501</guid>
      <author>pvdb (Peter Vandenberk)</author>
    </item>
    <item>
      <title>Loading a property file from the classpath</title>
      <link>http://snippets.dzone.com/posts/show/4479</link>
      <description>Loads a property file located anywhere in the classpath&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    private Properties getPropertiesFromClasspath(String propFileName) throws IOException {&lt;br /&gt;        // loading xmlProfileGen.properties from the classpath&lt;br /&gt;        Properties props = new Properties();&lt;br /&gt;        InputStream inputStream = this.getClass().getClassLoader()&lt;br /&gt;            .getResourceAsStream(propFileName);&lt;br /&gt;&lt;br /&gt;        if (inputStream == null) {&lt;br /&gt;            throw new FileNotFoundException("property file '" + propFileName&lt;br /&gt;                + "' not found in the classpath");&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        props.load(inputStream);&lt;br /&gt;&lt;br /&gt;        return props;&lt;br /&gt;    }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 30 Aug 2007 12:28:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4479</guid>
      <author>Archanciel (Jean-Pierre Schnyder)</author>
    </item>
    <item>
      <title>Loading an xml properties file</title>
      <link>http://snippets.dzone.com/posts/show/3945</link>
      <description>// simple example of loading an xml file into Properties.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Properties properties = new Properties();&lt;br /&gt;try {&lt;br /&gt;    InputStream xmlStream = getClass().getResourceAsStream("properties.xml");&lt;br /&gt;    if( xmlStream == null ) {&lt;br /&gt;         //throw some error&lt;br /&gt;    }            &lt;br /&gt;    properties.loadFromXML(xmlStream);&lt;br /&gt;} catch (IOException exception) {&lt;br /&gt;    // throw exception&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;br /&gt;&lt;!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"&gt;&lt;br /&gt;&lt;properties&gt;&lt;br /&gt;    &lt;entry key="plugin.TestPlugin"&gt;com.plugin.test.TestPluginModule&lt;/entry&gt;&lt;br /&gt;    &lt;entry key="messages.TestPlugin"&gt;TestPluginMessages.properties&lt;/entry&gt;&lt;br /&gt;&lt;/properties&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 02 May 2007 12:10:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3945</guid>
      <author>carlism (Carl Leiby)</author>
    </item>
    <item>
      <title>Change Text Properties on Mouseover</title>
      <link>http://snippets.dzone.com/posts/show/3319</link>
      <description>This only works with the IE browsers. Add this code within your &lt;head&gt; tags. To keep the underline on your links, replace "none" with "underline" Change "YourColor" with the hexidecimal number of color required.  &lt;br /&gt;Find this and other snippets on my site, if you wish, by &lt;a href="http://www.webscriptexpert.com/css-change-text-mouseover.html"&gt;clicking here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;style&lt;br /&gt;type="text/css"&gt; &lt;!-- A:link { text-decoration: none; color:#YourColor&lt;br /&gt;} A:visited { text-decoration: none; color:#YourColor } A:hover { text-decoration:&lt;br /&gt;none; color:#YourColor } --&gt; &lt;/style&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 17 Jan 2007 22:17:29 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3319</guid>
      <author>webscriptexpert (r)</author>
    </item>
    <item>
      <title>J2ME - System Properties</title>
      <link>http://snippets.dzone.com/posts/show/2020</link>
      <description>// System Properties J2ME&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;package System;&lt;br /&gt;&lt;br /&gt;import javax.microedition.lcdui.Alert;&lt;br /&gt;import javax.microedition.lcdui.AlertType;&lt;br /&gt;import javax.microedition.lcdui.Command;&lt;br /&gt;import javax.microedition.lcdui.CommandListener;&lt;br /&gt;import javax.microedition.lcdui.Display;&lt;br /&gt;import javax.microedition.lcdui.Displayable;&lt;br /&gt;import javax.microedition.lcdui.Form;&lt;br /&gt;import javax.microedition.midlet.MIDlet;&lt;br /&gt;import javax.microedition.midlet.MIDletStateChangeException;&lt;br /&gt;&lt;br /&gt;public class SystemProperties extends MIDlet implements CommandListener&lt;br /&gt;{&lt;br /&gt;	private Command esci;&lt;br /&gt;	&lt;br /&gt;	private Display display;&lt;br /&gt;	&lt;br /&gt;	private Form form;&lt;br /&gt;	&lt;br /&gt;	protected void startApp() throws MIDletStateChangeException&lt;br /&gt;	{&lt;br /&gt;		display = Display.getDisplay(this);&lt;br /&gt;		&lt;br /&gt;		form = new Form("System Propiertis");&lt;br /&gt;		form.setCommandListener(this);&lt;br /&gt;		&lt;br /&gt;		esci = new Command("Esci", Command.EXIT, 0);&lt;br /&gt;		form.addCommand(esci);&lt;br /&gt;		&lt;br /&gt;		Runtime rt = Runtime.getRuntime();&lt;br /&gt;		rt.gc(); // Garbage Collection&lt;br /&gt;		&lt;br /&gt;		form.append("Free Memory: " + rt.freeMemory() + "\n");&lt;br /&gt;		form.append("Total Memory: " + rt.totalMemory() + "\n");&lt;br /&gt;		form.append(showProp("microedition.configuration"));&lt;br /&gt;		form.append(showProp("microedition.platform"));&lt;br /&gt;		form.append(showProp("microedition.locale"));&lt;br /&gt;		form.append(showProp("microedition.encoding"));&lt;br /&gt;		form.append(showProp("microedition.encodingClass"));&lt;br /&gt;		form.append(showProp("microedition.http_proxy"));&lt;br /&gt;		&lt;br /&gt;		display.setCurrent(form);&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	protected void pauseApp()&lt;br /&gt;	{&lt;br /&gt;&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	protected void destroyApp(boolean unconditional) throws MIDletStateChangeException&lt;br /&gt;	{&lt;br /&gt;		notifyDestroyed();&lt;br /&gt;	}&lt;br /&gt;&lt;br /&gt;	public String showProp(String str)&lt;br /&gt;	{&lt;br /&gt;		String value = System.getProperty(str);&lt;br /&gt;		StringBuffer stringbuffer = new StringBuffer(50);&lt;br /&gt;		&lt;br /&gt;		stringbuffer.setLength(0);&lt;br /&gt;		stringbuffer.append(str);&lt;br /&gt;		stringbuffer.append(" = ");&lt;br /&gt;		&lt;br /&gt;		if(value == null)&lt;br /&gt;			stringbuffer.append("&lt;undefined&gt;");&lt;br /&gt;		else&lt;br /&gt;		{&lt;br /&gt;			stringbuffer.append("\"");&lt;br /&gt;			stringbuffer.append(value);&lt;br /&gt;			stringbuffer.append("\"");&lt;br /&gt;		}&lt;br /&gt;		&lt;br /&gt;		stringbuffer.append("\n");&lt;br /&gt;		&lt;br /&gt;		return stringbuffer.toString();&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public void commandAction(Command c, Displayable d)&lt;br /&gt;	{&lt;br /&gt;		if(c == esci)&lt;br /&gt;		{&lt;br /&gt;			try&lt;br /&gt;			{&lt;br /&gt;				destroyApp(true);&lt;br /&gt;			}&lt;br /&gt;			catch(MIDletStateChangeException e)&lt;br /&gt;			{&lt;br /&gt;				showException(e);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public void showException(Exception e)&lt;br /&gt;	{&lt;br /&gt;		Alert alert = new Alert("Errore !!!");&lt;br /&gt;		alert.setString(e.getMessage());&lt;br /&gt;		alert.setType(AlertType.ERROR);&lt;br /&gt;		alert.setTimeout(Alert.FOREVER);&lt;br /&gt;		&lt;br /&gt;		display.setCurrent(alert);&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Mon, 15 May 2006 01:57:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2020</guid>
      <author>whitetiger ()</author>
    </item>
  </channel>
</rss>
