Link to home
Start Free TrialLog in
Avatar of crisoft
crisoft

asked on

applet ----> URL -------> txt file

How can I do to access from an applet to an URL using "URL input stream" and from this URL to a txt file which is in a specific server?

I also need to know a way to read a txt file and extract strings, which are separated by something, for example a ",".


thank you very much
cristian

Avatar of jwilcox
jwilcox

For your way to extract strings you can use the StringTokenizer interface. Here is an example of how that works...

String FullOfColons = new String("My Mom;and I; went to the bank; and put in; a lot of money!); // Actually full of Semi-Colons!

StringTokenizer KillGrammar = new StringTokenizer(FullOfColons, ";", false) // False if you don't want the ; included, true if you do!

String RealSentence = new String();
while( KillGrammar.hasMoreTokens() )
{
  RealSentence += KillGrammar.nextToken();
}

System.out.println(RealSentence);

StringTokenizer is in java.util.

Hope this gets you atleast started on your solution.
To access a text file , access ot in the same way as you would a html file.
just make sure that you keep the text file in the Documents directory of your server
then access it using the URL.
For example

HTTP://yourservername/Doc.txt.

To parse through a string , refer to jwilcox's comment.
Avatar of crisoft

ASKER

HTTP://yourservername/Doc.txt.

Can you give me the code in java for this?
ASKER CERTIFIED SOLUTION
Avatar of vladi21
vladi21

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial