Solved

Java Programming question

Posted on 1997-07-05
4
471 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
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HSSFWorkbook cannot be resolved error 10 71
Opening PDF on button click and fill new document 2 39
throw exception 21 44
Which non-HTML GUI front end to use with Java? 3 22
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

803 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