• 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

Error with FileInputStream

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Chan
This is the error i got..
 
Chan Ag
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 1090
14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic