1 package prefuse.data.io; 2 3 import java.io.File ; 4 import java.io.FileInputStream ; 5 import java.io.FileNotFoundException ; 6 import java.io.IOException ; 7 import java.io.InputStream ; 8 import java.net.URL ; 9 10 import prefuse.data.Table; 11 import prefuse.util.io.IOLib; 12 13 14 21 public abstract class AbstractTableReader implements TableReader { 22 23 26 public Table readTable(String location) throws DataIOException 27 { 28 try { 29 InputStream is = IOLib.streamFromString(location); 30 if ( is == null ) 31 throw new DataIOException("Couldn't find " + location 32 + ". Not a valid file, URL, or resource locator."); 33 return readTable(is); 34 } catch ( IOException e ) { 35 throw new DataIOException(e); 36 } 37 } 38 39 42 public Table readTable(URL url) throws DataIOException { 43 try { 44 return readTable(url.openStream()); 45 } catch ( IOException e ) { 46 throw new DataIOException(e); 47 } 48 } 49 50 53 public Table readTable(File f) throws DataIOException { 54 try { 55 return readTable(new FileInputStream (f)); 56 } catch ( FileNotFoundException e ) { 57 throw new DataIOException(e); 58 } 59 } 60 61 } | Popular Tags |