Results 1 to 7 of 7
  1. #1
    ErtanTaboo is offline Member
    Join Date
    Jun 2015
    Posts
    14
    Rep Power
    0

    Default Whythis code is not working?

    Hello everyone ,I wanted to do something like: When the button is pressed: to save documents .txt (the documents names should be classes names) , i made a simple code but its not woriking , can anyone help me?

    Java Code:
         int i=0;
                           String filename = (String)klaset1.getItemAt(i);
                           
                            try {
                                
                                FileWriter fw = new FileWriter("C:/Users/Ertan/Desktop/Orari/" + filename +".txt");
                                BufferedWriter bw = new BufferedWriter(fw);
                                bw.write("HELLO");
                                bw.close();
                                
                            } catch (Exception ex) {
                                Logger.getLogger(Gui.class.getName()).log(Level.SEVERE, null, ex);
                            }
                            i++;

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Whythis code is not working?

    its not woriking
    Please explain. What does the code do when compiled and executed?
    What do you want it to do?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    ErtanTaboo is offline Member
    Join Date
    Jun 2015
    Posts
    14
    Rep Power
    0

    Default Re: Whythis code is not working?

    Quote Originally Posted by Norm View Post
    Please explain. What does the code do when compiled and executed?
    What do you want it to do?
    When I click on the button , it create only one document (will one class name) , i need to create as much documents as classes.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Whythis code is not working?

    So either:

    - that code you posted is working perfectly, as it creates only one document exactly as you say happens

    - you did not post all the relevant code and the part that is supposed to repeat the above code is missing
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Whythis code is not working?

    need to create as much documents as classes.
    That sounds like the code needs a loop to go through all the classes.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    ErtanTaboo is offline Member
    Join Date
    Jun 2015
    Posts
    14
    Rep Power
    0

    Default Re: Whythis code is not working?

    Quote Originally Posted by Norm View Post
    That sounds like the code needs a loop to go through all the classes.
    Yep i just createt a for loop and it works great . Thank you.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    26

    Default Re: Whythis code is not working?

    Nothing to do with AWT/Swing. Moving to New to Java.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. non working code :S
    By walsby14 in forum New To Java
    Replies: 6
    Last Post: 07-17-2012, 08:52 PM
  2. Replies: 1
    Last Post: 03-25-2012, 03:40 AM
  3. Replies: 2
    Last Post: 01-04-2011, 04:30 AM
  4. JNI: Why this code not working?
    By playwin2 in forum Advanced Java
    Replies: 5
    Last Post: 11-25-2008, 01:12 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
  •