/jEdit/tags/jedit-4-1-pre5/bsh/commands/cat.bsh
Unknown | 45 lines | 38 code | 7 blank | 0 comment | 0 complexity | 6164aa4f836c4c1388f5a706d151c16d 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 )
- {
- 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 )
- {
- bin = new BufferedReader( new InputStreamReader( ins ) );
- cat( bin );
- }
- cat( Reader reader )
- {
- try {
- bin = new BufferedReader( reader );
- while ( (line=bin.readLine() ) != null )
- print( line );
- } catch ( Exception e ) {
- print( "Error reading stream:"+ e);
- }
- }