PageRenderTime 46ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/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
  1. /**
  2. Print the contents of filename, url, or stream (like Unix cat)
  3. */
  4. bsh.help.cat = "usage: cat( filename )";
  5. /**
  6. cat comment
  7. */
  8. cat( String filename )
  9. {
  10. this.file = pathToFile( filename );
  11. if ( !file.exists() || !file.canRead() ) {
  12. print( "Can't read " + file );
  13. return;
  14. }
  15. cat( new FileReader( file ) );
  16. }
  17. /**
  18. cat comment
  19. */
  20. cat( URL url )
  21. {
  22. cat( url.openStream() );
  23. }
  24. cat( InputStream ins )
  25. {
  26. this.bin = new BufferedReader( new InputStreamReader( ins ) );
  27. cat( bin );
  28. }
  29. cat( Reader reader )
  30. {
  31. try {
  32. this.bin = new BufferedReader( reader );
  33. while ( (this.line=bin.readLine() ) != null )
  34. print( line );
  35. } catch ( Exception e ) {
  36. print( "Error reading stream:"+ e);
  37. }
  38. }