Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you want a method to use an object you have as a local variable you can pass its as an argument. This is standard practice in just about every language I can think of. However instead of passing the FileInputStream it is better to pass the file name in camelCase</p> <pre><code>// in main process(requestFile, responseFile, logFile); // later public static void process(String requestFile, String responseFile, String logFile) throw IOException { //Connect to the Request Input File FileInputStream requestIn = new FileInputStream(requestFile); //Connect to the Response Output File FileOutputStream responseOut = new FileOutputStream(responseFile); //Connect to the Request/Response Log File FileOutputStream logOut = new FileOutputStream(logFile); requestIn.close(); responseOut.close(); logOut.close(); } </code></pre> <blockquote> <p>I get a bunch of "symbol not found" error messages. </p> </blockquote> <p>Because a local variable is local to the scope i.e. the method it is in. You can't use it in another method.</p> <blockquote> <p>Again, if I put "public" in front of the file I/O constructors, I get the Illegal expression message.</p> </blockquote> <p>Because public fields cannot be defined in a method, they have to be define outside a method, usually at the start of the class.</p> <blockquote> <p>Is there any way out of this ??? </p> </blockquote> <p>Reading a few tutorials <a href="http://www.google.com/search?q=java+turorials" rel="nofollow">http://www.google.com/search?q=java+turorials</a> 11 million results, or working example <a href="http://www.google.com/search?q=java+examples" rel="nofollow">http://www.google.com/search?q=java+examples</a> 25 million results </p> <blockquote> <p>Why the java compiler insists on the program handling file-not-found errors is beyond me. I mean there's already the If file_object.exists() method... IF the file's NOT there..the OS will let you know. </p> </blockquote> <p>It does let you know by throwing a FileNotFoundException. What do you expect it to do?</p> <blockquote> <p>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> </blockquote> <p>And the OS can return an error which you need to be able to handle.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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