When I access internet through my
java application from my home i.e. no proxy server, then I am able to get access to it.
But when I try to access internet from my office where there is a proxy server, I get a unkownhostexception and none of the java applications making using of java.net package execute.
Please help me find out the solution to this problem.
// sample code
import java.net.*;
import java.io.*;
public class SourceViewer
{
public static void main(
String args[])
{
URL url;
try{
if (args.length > 0)
url = new URL(args[0]);
else
url = new URL("http://www.microsoft.com");
URLConnection uc = url.openConnection();
InputStream raw = uc.getInputStream();
InputStream buffer = new BufferedInputStream (raw);
Reader r = new InputStreamReader(buffer);
int c;
while ((c = r.read()) != -1)
{
System.out.print((char) c);
}
}
catch(MalformedURLException e)
{
System.err.println("Invalid URL");
}
catch(IOException e)
{
System.err.println(e);
}
}// main
}// class SView