Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading a data file in an applet

 
Jaya Chakra
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I read a data file through an applet that uses awt.
 
Devu Nair
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jaya,
From your question it is not clear what type of data you want to read ( HTML, image, video, audio, or some other type of document, such as a Java class file ).
URL home = new URL ("http://www.filename.*");
Object page = home.getContent();
I'm not sure whether this is going to help you.
Any way try this out
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jaya,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
David G Risner
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally like to use getClass().getResourceAsStream("datafile") to get an InputStream that I can then use to read the file.
The data file needs to be found in the same directory as the class file (or within the jar file the class file is from in the same directory within the jar file).
You can put a "/" at the beginning of the data file name if you want to place the data file at the root of the codebase (or the root of the jar file).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic