Home Tutorial Php Examples Converting the text files into bzip file.

 
 

Converting the text files into bzip file.
Posted on: July 30, 2009 at 12:00 AM
Advertisement
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. 

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

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

Advertisement

Related Tags for Converting the text files into bzip file.:


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.

Posted on: July 30, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com