This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Error with FileInputStream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Error with FileInputStream" Watch "Error with FileInputStream" New topic
Author

Error with FileInputStream

Andy Richard
Ranch Hand

Joined: Oct 22, 2013
Posts: 47
I just made my first I/O code stuff..just to implement what i read and understood.
But the following code produces error..


Can anyone help me with that??
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1000
    
  16
Andy Richard wrote:I just made my first I/O code stuff..just to implement what i read and understood.
But the following code produces error..
.......................
Can anyone help me with that??


What does the compiler error say?

Hint : It is telling us which line has the error and it says why the compilation has failed.

Chan.
Andy Richard
Ranch Hand

Joined: Oct 22, 2013
Posts: 47
@Chan
This is the error i got..
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1000
    
  16
Andy Richard wrote:@Chan
This is the error i got..


Are you sure you have posted the same code here? The source code that you have posted is of 'check.java' whereas that error suggests you are trying to run some 'Check' class which would have been created if some 'Check.java' had successfully compiled.

By the way, the source code you have posted gives me the following compilation error ( I added the missing closing brace at the end of your code or that would have given me a different compilation error ).

C:\Users\myPath>javac check.java
check.java:36: cannot find symbol
symbol : method getType()
location: class check
System.out.println("Variable, stored contains.." + stored.getType());
^
1 error


Since compilation is not successful, the .class file is not formed and hence java cannot find the class if you try to execute it.
C:\Users\myPath>java check
Error: Could not find or load main class check

If you try to run a java program in an IDE without resolving the compilation error ( this is what we shouldn't do - cause executing a program requires the class file which is the output of a successful compilation process ), the IDE gives you the following kind of a message.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
< the description of the compilation error>


So for the source code you have posted, I would get the following error.
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method getType() is undefined for the type check

at threadandsynchronization.check.main(check.java:40)

Andy Richard
Ranch Hand

Joined: Oct 22, 2013
Posts: 47
well Chan,
i edited to the actual error i got.. i placed tat whole stuff in a 'javaApplication9' package.. and a JavaApplication Class.. so just to make it look good name wise, i made the name as check here.
You are right, its the same error i'm getting you talked about..
But, how should i resolve the compilation error i get??
Chan Ag
Bartender

Joined: Sep 06, 2012
Posts: 1000
    
  16
It's telling you exactly what and where the error is.

If you click on check.java:<line number> it will take you exactly where the error is. The line it takes me to is -



The error is "The method getType() is undefined for the type check".

So it is telling you that getType() method is not defined in type( class ) check. So either define ( code ) it in class check or replace stored.getType() with what was intended.
 
Don't get me started about those stupid light bulbs.
 
subject: Error with FileInputStream
 
Similar Threads
Serialization problem
class invalid for deserialization
How to know the number of items in your Seralization/Deserialization stream?
serialization example of kathy siera book(page no-471)
basic concepts on Serialization