avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-apps/enterprise/orb/src/java/org/apache/orb/util IOR.java package.html
Date Sat, 09 Mar 2002 05:11:44 GMT
mcconnell    02/03/08 21:11:44

  Added:       enterprise/orb/src/java/org/apache/orb/util IOR.java
                        package.html
  Log:
  utils addition
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-apps/enterprise/orb/src/java/org/apache/orb/util/IOR.java
  
  Index: IOR.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.TXT file.
   *
   * Original contribution by OSM SARL, http://www.osm.net
   */
  
  package org.apache.orb.util;
  
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.PrintWriter;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.BufferedReader;
  import java.net.URL;
  import java.net.URLConnection;
  
  import org.omg.CORBA.ORB;
  
  
  /**
   * General utilities supporting the reading and writing of an IOR to and from a file.
   */
  
  public class IOR
  {
          
     /**
      * Write an IOR to a file.
      */
      
      public static void writeIOR( ORB orb, org.omg.CORBA.Object object, String filename )
throws IOException
      {
          FileOutputStream file = new FileOutputStream( filename );
          PrintWriter pfile = new PrintWriter( file );
          pfile.println( orb.object_to_string( object ));
          pfile.close();
      }
      
     /**
      * Read an IOR from a file.
      */
      
      public static org.omg.CORBA.Object readIOR( ORB orb, String filename ) throws FileNotFoundException,
IOException
      {
  	  if( filename.indexOf("://") > -1 ) return readIOR( orb, new URL( filename ));
  
          FileInputStream file = new FileInputStream( filename );
          InputStreamReader input = new InputStreamReader( file );
          BufferedReader reader = new BufferedReader(input);
          String stringTarget = reader.readLine();
          return orb.string_to_object( stringTarget );
      }
  
     /**
      * Read an IOR from a URL.
      */
   
      public static org.omg.CORBA.Object readIOR( ORB orb, URL url ) throws IOException
      {
          URLConnection connection = url.openConnection();
          InputStream input = connection.getInputStream();
          BufferedReader buffer = new BufferedReader( new InputStreamReader(input) );
          String IOR = buffer.readLine();
          buffer.close();
          return orb.string_to_object( IOR );
      }
  }
  
  
  
  1.1                  jakarta-avalon-apps/enterprise/orb/src/java/org/apache/orb/util/package.html
  
  Index: package.html
  ===================================================================
  
  <body>
  <p>General utilities.</p>
  </body>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message