/jEdit/tags/jedit-4-3-pre5/bsh/commands/cat.bsh
Unknown | 45 lines | 38 code | 7 blank | 0 comment | 0 complexity | 89d353dc36e62d1bd5c258021c0bdcdb MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /**
- Print the contents of filename, url, or stream (like Unix cat)
- */
- bsh.help.cat = "usage: cat( filename )";
- /**
- cat comment
- */
- cat( String filename )
- {
- this.file = pathToFile( filename );
- if ( !file.exists() || !file.canRead() ) {
- print( "Can't read " + file );
- return;
- }
- cat( new FileReader( file ) );
- }
- /**
- cat comment
- */
- cat( URL url )
- {
- cat( url.openStream() );
- }
- cat( InputStream ins )
- {
- this.bin = new BufferedReader( new InputStreamReader( ins ) );
- cat( bin );
- }
- cat( Reader reader )
- {
- try {
- this.bin = new BufferedReader( reader );
- while ( (this.line=bin.readLine() ) != null )
- print( line );
- } catch ( Exception e ) {
- print( "Error reading stream:"+ e);
- }
- }