small problems that seem impossible to find in the javaAPI


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: small problems that seem impossible to find in the javaAPI

  1. #1
    Join Date
    Dec 2005
    Posts
    1

    small problems that seem impossible to find in the javaAPI

    Hello, I have some minor problems I hoped someone here would know the answers to;

    my first question is how to resize an applet, I've checked the API and found the resize(int width, int height) method, but where am I supposed to use it?
    in the init? in the head? tried most places...

    the second question is how to break rows when writing to a file with FileWriter, I've tried \n like in C, but it does not seem to work, and it's impossible to find any info on those kind of basic operators o_O

    and lastly the third problem... I can't seem to get my program to utilize the write-to-file method I wrote, here is the relevant code;



    .
    .
    .

    historyWriter(historyEntryH, historyEntryT); //here's the call, and here's where I get the error
    }
    }
    }

    public void historyWriter(String H, String T) // and here is the method
    throws IOException
    {
    File historyFile = new File(outputDirT.getText());
    FileWriter writer = new FileWriter(historyFile, true);
    writer.write(H + " / " + T + '\n' + " <|> ");
    writer.close();
    }


    the method works fine if I call it externally, but as soon as I try to call it from the other method above I get "must be declared or thrown"

    if I proceed to change the above code to
    try
    {
    historyWriter(historyEntryH, historyEntryT);
    }
    catch(IOException e)
    {}

    I can proceed and compile the program, but it doesnt work (it wont write to the file in question, and the for-loop the call is in stops working properly)

    it's probably a simple mistake, does anyone have any good ideas? ^_^

  2. #2
    Join Date
    Oct 2005
    Posts
    107
    It's been a while but I think you use the setSize method in init.

    when I write text to a file I'll use a PrintWriter. It makes it super easy to write a line break.

    PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(targetFile)));
    ...
    writer.println("Some String");

    Also if your writing to a file from an applet you could run into problems because of the security setup for applets. You can read from files in an applet though.
    Last edited by Joe Beam; 12-12-2005 at 02:23 PM.

Similar Threads

  1. Issue with VS.NET Find
    By Beginner in forum .NET
    Replies: 0
    Last Post: 01-27-2002, 06:35 PM
  2. Find Method with Multiple Criteria
    By Karl Robinson in forum VB Classic
    Replies: 7
    Last Post: 07-23-2001, 11:58 AM
  3. SQL Tutorial (Answer Q's & post your reply)
    By bigbastard4 in forum Database
    Replies: 2
    Last Post: 05-16-2001, 07:24 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center