We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,492 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

need help in my save code..

hi
im not very good in english .. XD
im trying to make a simple text editor that can open and save..

i have a problem in my save code
here is the code:

JFileChooser jfc = new JFileChooser();
        jfc.showSaveDialog(jMenuItem1);

        File f = jfc.getSelectedFile();
        try {

            FileWriter fr = new FileWriter(f);
            BufferedWriter bw = new BufferedWriter(fr);

            String line = "";


                     bw.write(jTextArea1.getText());

                     bw.flush();
                     jTextArea1.append(line);
                     jTextArea1.append("\n");


                     bw.close();
        }catch (Exception e) {
            System.err.println(e);
            System.exit(1);
        }

it can already save
the problem is that when i input:

sample

output

the output is

sampleoutput
2
Contributors
3
Replies
1 Week
Discussion Span
10 Months Ago
Last Updated
4
Views
crL0000
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Can you make a small complete programn that compiles, executes and shows the problem?

Is the problem with the output that it is missing the line end characters?

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

yes the problem is the line ..

crL0000
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Can you make a small complete programn that compiles, executes and shows the problem?

NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page generated in 0.0598 seconds using 2.66MB