Solved

Java Programming question

Posted on 1997-07-05
4
478 Views
Last Modified: 2008-03-03
what is the problem for the code?

import java.net.*;
import java.io.*;
import java.awt.*;
class sortClient
{
        URL sortURL;
        URLConnection connection;
        PrintStream outStream;
        public sortClient()
        {
                try
                {
                sortURL=new                 URL("http://xxx.xx.xx/~xxxxxx/file.dat");
                connection=sortURL.openConnection();
                outStream=new PrintStream(connection.getOutputStream());
             
                }
                catch (MalformedURLException mfURLe)
                {
                        System.out.println(mfURLe);
                }
                catch (IOException ioe)
                {
                        System.out.println(ioe);
                }

        }
}
public class test extends java.applet.Applet
{
        sortClient a;
        public void init()
        {
                a=new sortClient();
        }

}



0
Comment
Question by:ccst
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:byoung
ID: 1222681
What error are you getting? That would help greatly
0
 
LVL 2

Expert Comment

by:webster030697
ID: 1222682
I think I see your problem. In your first section of code you left out:

import java.applet.*;
0
 

Author Comment

by:ccst
ID: 1222683
When I run the applet. Error message display (java.net.ProtocolException: cannot write to a URLConnection if doOutput=false call setDoOutput(true))



0
 
LVL 1

Accepted Solution

by:
froderik earned 10 total points
ID: 1222684
You are not supposed to write to any files anywhere when using applets. The only thing an applet can do with files is reading. This is for security reasons.

If you really want to write to files you have some options. The nicest in Java is the socket solution where you have an Java aplication running on the server which you can access from Java clients, applets or applications, to read and write to files. In this way you get moch more control over the i/o process.

If you want some good resources on things like this please let me know.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jboss 7.1 start up error 1 81
ejb mdb examples 1 36
Java syntax, or is it Selenium 6 57
activeMQ Queue Messages Enqueued and Messages Dequeued 1 96
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

739 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