Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Reading and writing files

  Asked By: Kiswar    Date: Jan 29    Category: Java    Views: 1032
  

I'm having a problem opening a file from my JFileChooser code. I've
written the code and it compiles no problem so I now have a Frame
with menu and when I click on open, I get the next window with the
file list, choosing a file has no affect.

What do I need to use... FileInputStream / FileOutputStream
How much code will be involved.

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Mark R     Answered On: Jan 29

JFileChooser only give you a list  of files  you had
not. You still have to use file  read and write.
There are more complicate way to search and retrieve
files, but stick with the basic just to see if it's
working out OK.

 
Answer #2    Answered By: Jaime Bowman     Answered On: Jan 29

ok thanks. What is my best option... FileReader or FileOutputStream or something
like that? How many lines of code  do you reckon it should take?

 
Answer #3    Answered By: Brandon Tucker     Answered On: Jan 29

for text file  you should use FileReader and for binary , you could use
FileInputStream...

code is like :
try {
reader = new BufferedReader(new FileReader(fileName));
} catch (FileNotFoundException e) {e.printStackTrace();}

then you could read it line by line using method BufferedReader.readLine() ;

 
Didn't find what you were looking for? Find more on Reading and writing files Or get search suggestion and latest updates.




Tagged: