Results 1 to 4 of 4
- 07-08-2010, 09:32 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 12
- Rep Power
- 0
FileInputStream not recognising file
I am having trouble with the following code getting error
Buttons.java:339:cannot find symbol
symbol :variable curFile
location :class Buttons
{FileInputStream f_in = new FileInputStream(curFile);
^
I have put a system.out line above and it recognises it there
A similar dialog for writing seems to be accepted
Java Code:{teachPanel.setVisible(true); questPanel.setVisible(false); File f = new File(thingsName+".zzz");// set to existing file chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setSelectedFile(f); int returnVal=chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION)//file selected {File curFile=new File(""); curFile = chooser.getSelectedFile(); System.out.println("File Type= "+curFile);} else {return;} //read file here try {FileInputStream f_in = new FileInputStream (curFile); //problem line ObjectInputStream obj_in = new ObjectInputStream (f_in); Object obj=obj_in.readObject(); scores =(int[][]) obj; //cast obj to array Object obj1=obj_in.readObject(); props=(String[])obj1; Object obj2=obj_in.readObject(); things=(String[])obj2;} /
- 07-08-2010, 09:39 PM #2
curFile is out of scope, you define it in the if block, and that's the only place where it's visible.
And your bracing style is atrocious!Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 07-08-2010, 09:44 PM #3
Member
- Join Date
- Jun 2010
- Posts
- 12
- Rep Power
- 0
solved
PhHein,
many thanks -had looked at it for ages - the braces are the result of frustrated attempts to get to the bottom of it. I was thrown by the similar code working for writing - but if scope was different there
- 07-08-2010, 09:52 PM #4
Glad you sorted it out, please mark the thread as solved in the thread tools menu above your original post.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Similar Threads
-
FileInputStream
By pachufir in forum New To JavaReplies: 3Last Post: 12-11-2009, 05:07 PM -
NullPointerException in FileInputStream text file
By cheskers11 in forum EclipseReplies: 1Last Post: 11-19-2009, 01:38 PM -
FileOutputStream > int > FileInputStream
By dudejonne in forum New To JavaReplies: 11Last Post: 11-11-2009, 04:03 PM -
Alternative of FileInputStream to read Property File
By SE123 in forum Java ServletReplies: 13Last Post: 09-16-2009, 01:05 PM -
[SOLVED] Trouble with Scanner FileInputStream not finding the file
By miss.meli in forum New To JavaReplies: 0Last Post: 12-01-2008, 09:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks