| Home >> All >> com >> memoire >> [ foo Javadoc ] |
Source code: com/memoire/foo/FooInputStream.java
1 /** 2 * @modification $Date: 2002/12/16 18:56:26 $ 3 * @statut unstable 4 * @file FooInputStream.java 5 * @version 0.08 6 * @author Guillaume Desnoix 7 * @email guillaume@desnoix.com 8 * @license GNU General Public License 2 (GPL2) 9 * @copyright 1999-2001 Guillaume Desnoix 10 */ 11 12 package com.memoire.foo; 13 import com.memoire.foo.*; 14 15 import java.io.*; 16 17 public class FooInputStream 18 { 19 private static FooCategory pkg_=null; 20 21 public static final FooCategory init() 22 { 23 if(pkg_==null) 24 { 25 pkg_=FooCategory.create(InputStream.class); 26 27 pkg_.setMessage(">>",FooInputStream.class,"read"); 28 pkg_.setMessage("->",FooInputStream.class,"readAll"); 29 } 30 31 return pkg_; 32 } 33 34 public static byte[] readAll(InputStream _in) 35 { 36 byte[] r=null; 37 38 try 39 { 40 ByteArrayOutputStream out=new ByteArrayOutputStream(); 41 while(_in.available()>0) out.write(_in.read()); 42 r=out.toByteArray(); 43 } 44 catch(Exception ex) 45 { 46 throw new RuntimeException 47 (FooLib.getClassName(ex.getClass())+":"+ex.getMessage()); 48 } 49 50 return r; 51 } 52 53 public static Object read(InputStream _in) 54 { 55 Object r=null; 56 FooParser parser=FooLib.getParser(); 57 synchronized (parser) 58 { 59 //FooTokenizer old=parser.getTokenizer(); 60 try 61 { 62 r=parser.parseExpr(false,false); 63 } 64 catch(IOException ex) { } 65 //parser.setTokenizer(old); 66 } 67 return r; 68 } 69 }