<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>DataMaskin</title>
	<atom:link href="http://datamaskin.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://datamaskin.wordpress.com</link>
	<description>Java,Flex and technology related posts</description>
	<lastBuildDate>Thu, 19 Mar 2009 18:18:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='datamaskin.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/e183592a24cfbed23619ac279a7d4ad4?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>DataMaskin</title>
		<link>http://datamaskin.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://datamaskin.wordpress.com/osd.xml" title="DataMaskin" />
	<atom:link rel='hub' href='http://datamaskin.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Compress and Extract files to Tar format with Java</title>
		<link>http://datamaskin.wordpress.com/2009/03/19/compress-and-extract-files-to-tar-format-with-java/</link>
		<comments>http://datamaskin.wordpress.com/2009/03/19/compress-and-extract-files-to-tar-format-with-java/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 17:25:01 +0000</pubDate>
		<dc:creator>Madan Chowdary</dc:creator>
				<category><![CDATA[1]]></category>

		<guid isPermaLink="false">http://datamaskin.wordpress.com/?p=6</guid>
		<description><![CDATA[Today i had a requirement to compress and extract list of files to a tar file in Java. Googling over net and found this library http://www.trustice.com/java/tar/ . I couldnt find the examples for using the library. Tried out a bit and got it up working. So just posting out the code that could compress and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=datamaskin.wordpress.com&amp;blog=1010860&amp;post=6&amp;subd=datamaskin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="font-family:verdana;">Today i had a </span><span class="blsp-spelling-corrected"><span style="font-family:verdana;">requirement</span></span><span style="font-family:verdana;"> to compress and extract list of files to a tar file in Java.</span></p>
<div><span style="font-family:verdana;">Googling over net and found this library  http://www.trustice.com/java/tar/ . I couldnt find the examples for using the library. </span></div>
<div><span style="font-family:verdana;"><br />
</span></div>
<div><span style="font-family:verdana;">Tried out a bit and got it up working. So just posting out the code that could compress and extract files to/from a TAR File.</span></div>
<div><span style="font-family:verdana;"><br />
</span></div>
<div><span style="font-family:verdana;"><span style="text-decoration:underline;"><strong>Compressing files to Tar File :</strong></span></span></div>
<pre><span style="font-family:verdana;"><code>private File compressFilesToTarFile(List files) throws Exception {
 TarEntry tarEntry = null;
 File tarFile = new File(CommonConstants.ROOT_BACKUP_FOLDER+File.separator+CommonConstants.LOGS_BACKUP_FOLDER+File.separator +buildGeneratedTarFileName());
 tarFile.createNewFile();
 OutputStream outputStream = new FileOutputStream(tarFile);
 TarOutputStream tarOutputStream = new TarOutputStream(outputStream);
 for(File file : files)
 {
 tarEntry = new TarEntry(file);
 tarOutputStream.putNextEntry(tarEntry);
 tarOutputStream.write(getBytesFromFile(file));
 tarOutputStream.closeEntry();
 }
 tarOutputStream.close();
 return tarFile;
}

private static byte[] getBytesFromFile(File file) throws Exception {
 InputStream is = new FileInputStream(file);
 // Get the size of the file
 long length = file.length();
 if (length &gt; Integer.MAX_VALUE) {
    // File is too large
}
 // Create the byte array to hold the data
 byte[] bytes = new byte[(int)length];
 // Read in the bytes
 int offset = 0;
 int numRead = 0;
 while (offset &lt;bytes.length  &amp;&amp; (numRead=is.read(bytes, offset, bytes.length-offset)) &gt;= 0) {
      offset += numRead;
 }
 // Ensure all the bytes have been read in
 if (offset &lt;bytes.length) {
  throw new Exception("Could not completely read file "+file.getName());
 }
 // Close the input stream and return bytes
 is.close();
 return bytes;
}
</code>
</span></pre>
<div><span style="text-decoration:underline;"><strong>Extracting files from Tar File</strong></span></div>
<pre><code>private static void untarBaseUpgradeFile(File tarFile, File dest) throws Exception
{
dest.mkdir();
TarInputStream tin = new TarInputStream(new GZIPInputStream(new FileInputStream(tarFile)));
TarEntry tarEntry = tin.getNextEntry();
while (tarEntry != null)
{
  File destPath = new File(dest.toString() + File.separatorChar + tarEntry.getName());
  if (tarEntry.isDirectory()) {
    destPath.mkdir();
  }
  else {
    FileOutputStream fout = new FileOutputStream(destPath);
    tin.copyEntryContents(fout);
    fout.close();
  }
  tarEntry = tin.getNextEntry();
}
tin.close(); tin = null;
}
</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/datamaskin.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/datamaskin.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/datamaskin.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=datamaskin.wordpress.com&amp;blog=1010860&amp;post=6&amp;subd=datamaskin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://datamaskin.wordpress.com/2009/03/19/compress-and-extract-files-to-tar-format-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5b11665aa50a9791dd3655c2279647f?s=96&#38;d=identicon" medium="image">
			<media:title type="html">datamaskin</media:title>
		</media:content>
	</item>
		<item>
		<title>All New Expence Manager &#8211; Buxfer.com</title>
		<link>http://datamaskin.wordpress.com/2007/04/22/all-new-expence-manager-buxfercom/</link>
		<comments>http://datamaskin.wordpress.com/2007/04/22/all-new-expence-manager-buxfercom/#comments</comments>
		<pubDate>Sun, 22 Apr 2007 14:23:25 +0000</pubDate>
		<dc:creator>Madan Chowdary</dc:creator>
		
		<guid isPermaLink="false">http://datamaskin.wordpress.com/2007/04/22/all-new-expence-manager-buxfercom/</guid>
		<description><![CDATA[The New Expense Manager/Analyzer , Buxfer (www.buxfer.com) means Budget and Transactions. Its a Good Application for those who want to track there daily expenses and in a clear way to know on what they spent for the whole month/year. The site has all the features for mainatining, reporting the transactions done by you, or amount [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=datamaskin.wordpress.com&amp;blog=1010860&amp;post=4&amp;subd=datamaskin&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The New Expense Manager/Analyzer , Buxfer (<a href="http://www.buxfer.com" target="_blank">www.buxfer.com</a>) means Budget and Transactions.</p>
<p>Its a Good Application for those who want to track there daily expenses and in a clear way to know on what they spent for the whole month/year.</p>
<p>The site has all the features for mainatining, reporting the transactions done by you, or amount shared by you with your roommates/friends in a clear and simple way.</p>
<p>You can specify the category by means of Tags. The pie cart shown in the summary page will show the Tags and show a clear report on what category you have spent in percentage.</p>
<p>Still not yet fully implemented for extra features ,like exporting the report to an excel sheet or to a PDF, that would be useful to carry them or store for offline browsing.</p>
<p>Should await for these things in the coming days.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/datamaskin.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/datamaskin.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/datamaskin.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/datamaskin.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/datamaskin.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=datamaskin.wordpress.com&amp;blog=1010860&amp;post=4&amp;subd=datamaskin&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://datamaskin.wordpress.com/2007/04/22/all-new-expence-manager-buxfercom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c5b11665aa50a9791dd3655c2279647f?s=96&#38;d=identicon" medium="image">
			<media:title type="html">datamaskin</media:title>
		</media:content>
	</item>
	</channel>
</rss>
