Exposing objects defined in a method to another method
<p>I need to "expose" (I can't think of a better term) a set of objects 
(file channels, and bytebuffers) that are built in one method, but need to be accessed from another method. Tried using the public static accessors, but that only generated compiler errors. 
I have the "main" method e.g.</p>

<pre><code>public static void main(String args[]) throws IOException, FileNotFoundException
{ 
      ConnectFiles()  ; // builds the filestream, channel and bytebuffer objects
      ProcessRqst()   ; // reads the request file and writes to the response file
}   // end of main routine 

public static void ConnectFiles throws IOException 
{ 
     FileInputStream RqstInp = new FileInputStream(Rqst_File) ; 
     FileChannel RqstChnl  = RqstInp.getChannel() ; 
     ByteBuffer  Rqst_Bufr = ByteBuffer.allocate(RQbuflen) ; 

     //Connect to the Response Output File 
     FileOutputStream RespOut  = new FileOutputStream(Resp_File) ;
     FileChannel RespChnl =  RespOut.getChannel();
     ByteBuffer  Resp_Bufr = ByteBuffer.allocate(RSbuflen) ;
}   // end of connect-files routine 

public static void ProcessRqst() 
{  
    while ( pgm_status != EOF ) 
    {  
        try {
            RqstChnl.read( Rqst_Bufr ) ;    
            Rqst_Bufr.get( RqstWork, bufroffset, RQbuflen ) ;
        }  
        catch ( EOFException e ) 
        { 
            DT_Stamp = getDateTime() ;
            message_data.append(DT_Stamp) ;
            message_data.append(" LU62XCE0599: Request File at End-Of-File ") ;
            message_data.append(" Request File:") ; 
            message_data.append(Rqst_File) ;
            SendMesg() ; 
            pgm_status  = EOF ;    //set program status to End-Of-File 
        }
        catch ( IOException e ) 
        { 
            DT_Stamp = getDateTime() ;
            message_data.append(DT_Stamp) ;
            message_data.append(" LU62XnsCvr Method:ProcessRqsts ") ;
            message_data.append("Read Error Code:") ;
            message_data.append(AB_RQST) ; 
            message_data.append("  LU62XCE0513: Request File IO Exception =") ;
            message_data.append(" Request File:") ; 
            message_data.append(Rqst_File) ;
            SendMesg() ; 
            pgm_status  = READ_ERROR ;
        }
        if ( pgm_status == READ_ERROR )
            continue ;    //go back and read next record     

    //****  other stuff goes on ....


}  // end of Process Requests Routine
</code></pre>

<p>So I'm wondering does java afford a facile way of "exposing" a set of objects built in one method so they can be "accessed" in another method. </p>

<p>Now I do have a public class e.g.</p>

<pre><code>public class LU62XnsCvr extends Object 
  {   
</code></pre>

<p>where I have a lot of objects "declared" and accessable by all the methods in the program. 
However when I tried to define the FileInputStream and FileOutstream objects I got the 
IOException compile error; i.e the compiler "sees" these constructors as attempts at I/O 
operations, but no throws or try-catch has been "defined". </p>

<p>From what I've read I cannot code a "throws" exception on a class declaration. </p>

<p>I can build these objects within a method, but of course this "hides" the objects from 
other methods. </p>

<p>Please forgive me so being so "longwinded" ... but I'm just tryin' to get thru the "territory" </p>

<p>Thanks and Best Regards</p>

<p>Guy    </p>
