/* net_util.java Copyright 1998 Kyle R. Burton This is free software; you can redistribute it and/or modify it under the tearms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this software; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ /** * * file: net_util.java * * description: this file will hold utility classes and generic functions for * network communicaitons * * * revision list: * Tue Apr 28 15:32:46 EDT 1998 KRB - created the file * */ import java.net.*; import java.io.*; public class net_util { public static boolean show_diagnostics = false; public static int buff_size = 1024; // think unix style cat public static void CatURL( String url ) throws MalformedURLException, IOException { URL file_url; if( show_diagnostics ) { System.out.println("net_util::CatURL(String) url is: " + url ); } file_url = new URL(url); CatURL(file_url); } // spew text from url to stdout... public static void CatURL( URL url ) throws IOException { InputStream is; is = url.openStream(); byte buff[] = new byte[buff_size]; int bytes_read = 0; while(true) { bytes_read = is.read(buff); if( -1 == bytes_read ) { break; } if( 0 == bytes_read ) { continue; } System.out.print(new String(buff,0,bytes_read)); } } }