<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: stream code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 16:02:12 GMT</pubDate>
    <description>DZone Snippets: stream code</description>
    <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>Python - getFile Internet</title>
      <link>http://snippets.dzone.com/posts/show/2746</link>
      <description>// Scaricare un file dalla rete&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;package get.file.example;&lt;br /&gt;&lt;br /&gt;import java.io.BufferedInputStream;&lt;br /&gt;import java.io.FileOutputStream;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.net.MalformedURLException;&lt;br /&gt;import java.net.URL;&lt;br /&gt;&lt;br /&gt;public class GetFileExample&lt;br /&gt;{&lt;br /&gt;	public GetFileExample()&lt;br /&gt;	{&lt;br /&gt;		try&lt;br /&gt;		{&lt;br /&gt;			byte[] bite = new byte[2048];&lt;br /&gt;			int read;&lt;br /&gt;			URL url = new URL("http://switch.dl.sourceforge.net/sourceforge/pys60miniapps/FlickrS60_src_v0.1b.tar.bz2");&lt;br /&gt;			&lt;br /&gt;			BufferedInputStream bis = new BufferedInputStream(url.openStream());&lt;br /&gt;			FileOutputStream fos = new FileOutputStream("/tmp/file.tar.bz2");&lt;br /&gt;			&lt;br /&gt;			while((read = bis.read(bite))&gt;0)&lt;br /&gt;			{&lt;br /&gt;				fos.write(bite, 0, read);&lt;br /&gt;				System.out.println("--");&lt;br /&gt;			}&lt;br /&gt;			&lt;br /&gt;			fos.close();&lt;br /&gt;			bis.close();&lt;br /&gt;			&lt;br /&gt;			System.out.println("FINE");&lt;br /&gt;			&lt;br /&gt;		}&lt;br /&gt;		catch(MalformedURLException e)&lt;br /&gt;		{&lt;br /&gt;			e.printStackTrace();&lt;br /&gt;		}&lt;br /&gt;		catch(IOException e)&lt;br /&gt;		{&lt;br /&gt;			e.printStackTrace();&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	public static void main(String[] args)&lt;br /&gt;	{&lt;br /&gt;		new GetFileExample();&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 30 Sep 2006 22:35:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2746</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Reading a text file with StreamReader</title>
      <link>http://snippets.dzone.com/posts/show/2130</link>
      <description>&lt;br /&gt;&lt;code&gt;&lt;br /&gt;  private void ImportCountries()&lt;br /&gt;  {&lt;br /&gt;    string delimiter = ",";&lt;br /&gt;    string fileName = @"c:\countrylist3.csv";&lt;br /&gt;&lt;br /&gt;    StreamReader sr = new StreamReader(fileName);&lt;br /&gt;&lt;br /&gt;    try&lt;br /&gt;    {&lt;br /&gt;      while (sr.Peek() &gt;= 0)&lt;br /&gt;      {&lt;br /&gt;        string r = sr.ReadLine();&lt;br /&gt;        string[] items = r.Split(delimiter.ToCharArray());&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;    finally&lt;br /&gt;    {&lt;br /&gt;      sr.Close();&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 01 Jun 2006 18:05:39 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2130</guid>
      <author>casperskovgaard (Casper Skovgaard)</author>
    </item>
  </channel>
</rss>
