I have used a FileInputStream and InputStream reader to read from a file. I have a function which takes the filename and an OutputStream and then writes to the OutputStream. I want to declare the OutPutStream in main and then pass it to this function so I can write to the OutputStream. I would I declare an OutputStream and then pass it to this function so I can write to it. Thanks
Umm... simply pass the reference to the method and use it in there? If all you want to do is create it in main, but actually do the writing in another method, all you have to do is pass that reference to the method.
Joined: Nov 09, 2001
But how would I declare it in main. When I do this Outputstream out; and then pass out to the method, I get an error?
You need to say OutputStream out = null; not just OutputStream out; otherwise it'll give you an error saying 'out' hasn't been initialized or something. Jeff [ April 08, 2002: Message edited by: Jeff Smith ]