Note that there are some explanatory texts on larger screens.

plurals
  1. POHow best to make "accessable" File I/O Stream constructors (channel & ByteBuffer also)
    primarykey
    data
    text
    <p>I'd like to know how best to make "accessable" or "visible" a set of File I/O Stream constructors defined in my main routine, to sub-routines. </p> <p>I found that I cannot use "public", the compiler issues an "Illegal Expression" error msg. </p> <p>When I place the file I/O stream and channel constructors in the public class defined for the entire program "package". The compiler issues an error stating there's no FileNotFound or IOException handling declared, so I put on my mainline routine the following:</p> <pre><code>public static void main(String args[]) throws FileNotFoundException, IOException { // and if I then place the File I/O contructors after this: //Connect to the LU62XC Message File FileOutputStream MesgOut = new FileOutputStream(Mesg_File) ; FileChannel MesgChnl = MesgOut.getChannel() ; ByteBuffer Mesg_Bufr = ByteBuffer.allocate(128) ; //Connect to the Request Input File FileInputStream RqstInp = new FileInputStream(Rqst_File) ; //Connect to the Response Output File FileOutputStream RespOut = new FileOutputStream(Resp_File) ; //Connect to the Request/Response Log File FileOutputStream LogrOut = new FileOutputStream(Logr_File) ; </code></pre> <p>I resolve the "no exception handling error", but now my problem is the sub-routines that reference the "constructed" file objects essentianlly can't .. I get a bunch of "symbol not found" error messages. Again, if I put "public" in front of the file I/O constructors, I get the Illegal expression message. </p> <p>Is there any way out of this ??? </p> <p>Why the java compiler insists on the program handling file-not-found errors is beyond me. I mean there's already the if <code>file_object.exists()</code> method... </p> <p>IF the file's NOT there.. the OS will let you know. All ANY application program(OOP or otherwise) does when it comes to I/O of any kind is to make a request to the underlying OS. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload