Share on Google+Share on Google+

Converting the text files into bzip file.

This example will explain about converting text files into bzip file.

Converting text  file into bzip file

In this example, you will see, how to convert a text file into bzip file. In this example, we have printed 'I am a good programmer' along with converting a file into bzip file. 

Opne the PHP tag and first select a file to be converted into bzip file.

Open the file and write into bzip file

close the file. 

Again, open the file, and read it, close the file. 

close the php tag.

Select a file to be converted. into bzip file. 

# Read and Write a bz2 file
$bzfilename = "text.bz2";
$string = " I am a good programmer.\n";
$bz2 = bzopen($bzfilename, "w"); 
bzwrite($bz2, $string);
$bz = bzopen($bzfilename, "r");
echo bzread($bz2, 10);

The out put:
'I am a good programmer.'



Posted on: July 30, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null