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