• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

opening and saving using JFileChooser

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi masters

one of my current project needs a notepad like application,
in that we have to choose and save the files automatically

i have used JFileChooser and displayed the dialog box
but problem is i have to get that content of the file from the path and display in a JTextArea

i can get from from the file contents as characters if i use FileInputStream class

then i cannot append to JTextArea

so can u please give me a sample code for choosing a file and displaying in a <b>JTextArea </b> and saving it to a file name using JFileChooser
<b>It is very urgent</b>
Thanks in advance
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
once you got the content of your file stored as a string (or StringBuffer) use


hope that helps
[ June 22, 2004: Message edited by: Ben Buchli ]
 
shreehari Gopalakrishnan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But how can i get the files in string
I can get only as characters

please tell me how we can convert a char to String
 
Ben Buchli
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you may want to use a BufferedReader, that way you get each line of the file as a string...

something like this will work:

You need the try block because this code may throw a FileNotFoundException, or a IOException.

hope that helps
[ June 23, 2004: Message edited by: Ben Buchli ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the I/O and Streams forum...
reply
    Bookmark Topic Watch Topic
  • New Topic