Results 1 to 2 of 2
  1. #1
    loopsnhoops is offline Member
    Join Date
    Feb 2011
    Posts
    83
    Rep Power
    0

    Default Initializing FileWriter

    I am trying to initialize a FileWriter outside my constructor but it says I have to surround it with try and catch blocks which as we all know is impossible outside. I tried throwing the IO Exception but it gave me a compilation error. Ideas?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by loopsnhoops View Post
    I am trying to initialize a FileWriter outside my constructor but it says I have to surround it with try and catch blocks which as we all know is impossible outside. I tried throwing the IO Exception but it gave me a compilation error. Ideas?
    Either initialize it in the constructor or in a method.

Similar Threads

  1. Initializing a variable from another method
    By erikjd21 in forum New To Java
    Replies: 4
    Last Post: 04-17-2011, 09:55 AM
  2. Help with initializing error
    By GDW in forum New To Java
    Replies: 7
    Last Post: 10-20-2010, 09:10 PM
  3. Initializing variables using constructors
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-13-2008, 09:28 PM
  4. Initializing SAXParser
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-14-2007, 07:33 PM
  5. Initializing Arrays
    By bugger in forum New To Java
    Replies: 5
    Last Post: 11-09-2007, 10:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •