source: trunk/j/src/bsh/commands/cat.bsh @ 2

Last change on this file since 2 was 2, checked in by piso, 18 years ago

Initial checkin.

File size: 577 bytes
Line 
1
2bsh.help.cat = "usage: cat( filename )";
3
4cat( String filename )
5{
6  file = pathToFile( filename );
7
8  if ( !file.exists() || !file.canRead() ) {
9    print( "Can't read " + file );
10    return;
11  }
12
13  cat ( new FileReader( file ) );
14}
15
16cat( URL url )
17{
18  cat( url.openStream() );
19}
20
21cat( InputStream ins )
22{
23  bin = new BufferedReader( new InputStreamReader( ins ) );
24  cat( bin );
25}
26
27cat( Reader reader )
28{
29  try {
30    bin = new BufferedReader( reader );
31    while ( (line=bin.readLine() ) != null )
32      print( line );
33  } catch ( Exception e ) {
34    print( "Error reading stream:"+ e);
35  }
36}
Note: See TracBrowser for help on using the repository browser.