Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using java to download and run files in a applet

Posted on 2007-11-22
2
Medium Priority
?
238 Views
Last Modified: 2013-11-24
I am currently developing a project to match with an existing one and I'm attempting to create a web-based java applet that downloads a text file then opens it. I've attempted to do this already and failed.

The method I tried for downloading is (only a SMALL bit to allow better understandment) :
"URL url = new URL(address);
out = new BufferedOutputStream(
new FileOutputStream("C:\\temp\\" +localFileName));
conn = url.openConnection();
in = conn.getInputStream();"

I had a basic text for the applet using this:

"public void paint(Graphics g)
     {
      g.drawString("Please wait..",20,20);
      g.drawString("Retrieving file.",20,40);
}"

However, only the text bit showed. The downloading and running code simply didn't do its job. It passed compile and it works fine when I run the .class using batch, but the minute I jar it, it won't even run using a batch file nor applet. Basically, I want to know how to make a proper .jar applet that downloads and runs a file from a chosen URL (which will be in the same directory as the jar, on the same webserver).
0
Comment
Question by:HiTechFail
2 Comments
 
LVL 17

Expert Comment

by:contactkarthi
ID: 20336223
0
 
LVL 2

Accepted Solution

by:
HiTechFail earned 0 total points
ID: 20336664
They help a little, but still does not work after implementing into an applet.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question