File tree Expand file tree Collapse file tree
src/java/org/apache/commons/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,26 +46,24 @@ <h2>The <a href="IOUtils.html">org.apache.commons.io.IOUtils</a> class</h2>
4646< p > As an example, consider the task of reading bytes from a URL, and printing
4747them. This would typically done like this:</ p >
4848
49- < pre > import java.net.URL;< br > import java.io.*;< br > < br > public class ManualCopy {< br > public static void main(String args[]) throws IOException {< br > InputStream in = new URL( "http://jakarta.apache.org" ).openStream();< br > < font
50- color ="blue ">
51- InputStreamReader inR = new InputStreamReader( in );
49+ < pre > import java.net.URL;< br > import java.io.*;< br > < br > public class ManualCopy {< br > public static void main(String args[]) throws IOException {< br > InputStream in = new URL( "http://jakarta.apache.org" ).openStream();< br >
50+ < b > InputStreamReader inR = new InputStreamReader( in );
5251 BufferedReader buf = new BufferedReader( inR );
5352 String line;
5453 while ( ( line = buf.readLine() ) != null )
5554 {
5655 System.out.println( line );
57- }
58- </ font >
59- in.close();
56+ }</ b >
57+ in.close();
6058 }
6159}
6260 </ pre >
6361
6462< p > With the IOUtils class, that could be done with:</ p >
6563
66- < pre > import java.net.URL;< br > import java.io.*;< br > import org.apache.commons.io.IOUtils;< br > < br > public class IOUtilsCopy {< br > public static void main(String args[]) throws IOException {< br > InputStream in = new URL( "http://jakarta.apache.org" ).openStream();< br > < font
67- color =" blue " > System.out.println( IOUtils.toString( in ) );</ font >
68- in.close();
64+ < pre > import java.net.URL;< br > import java.io.*;< br > import org.apache.commons.io.IOUtils;< br > < br > public class IOUtilsCopy {< br > public static void main(String args[]) throws IOException {< br > InputStream in = new URL( "http://jakarta.apache.org" ).openStream();< br >
65+ < b > System.out.println( IOUtils.toString( in ) );</ b >
66+ in.close();
6967 }
7068}
7169 </ pre >
You can’t perform that action at this time.
0 commit comments