PageRenderTime 1ms CodeModel.GetById 120ms app.highlight 0ms RepoModel.GetById 40ms app.codeStats 0ms

/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
 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	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	bin = new BufferedReader( new InputStreamReader( ins ) );
33	cat( bin );
34}
35
36cat( Reader reader ) 
37{
38	try {
39		bin = new BufferedReader( reader );
40		while ( (line=bin.readLine() ) != null )
41			print( line );
42	} catch ( Exception e ) {
43		print( "Error reading stream:"+ e);
44	}
45}