Okay Tim
just for you.....
import java.net.*;
import java.io.*;
/** @modelguid {49C966E5-E164-4EB5-91C3-6807B466B6F4} */
public class socketTest
{
/** @modelguid {9EB91C8A-A2E2-41D4-B11D-372CCC597108} */
public static void main(String[] args) {
String html = sendSocket("www.amazon.com","GET","index.html","",80);
System.out.println(html);
}
/** @modelguid {D36EF506-B220-44B9-BAC4-CD20B8B8CB1D} */
public static String sendSocket(String host, String mode, String url,
String extras, int port)
{
StringBuffer outbound = new StringBuffer();
if(mode.equals("POST")) {
outbound.append(mode+": /"+url+" HTTP/1.0\n");
} else {
outbound.append(mode+": /"+url+"?"+extras+"
HTTP/1.0\n");
}
outbound.append("User-Agent: ForTim\n");
outbound.append("Host: "+host+"\n");
if(mode.equals("POST")) {
outbound.append("Content-length: "+ extras.length() +
"\n");
outbound.append("Content-type:
application/x-www-form-urlencoded\n");
}
outbound.append("Accept: image/gif, image/x-xbitmap,
image/jpeg,
image/pjpeg, */*\n\n");
if(mode.equals("POST")) {
outbound.append(extras + "\n");
}
System.out.println(outbound.toString());
StringBuffer stringbuffer = new StringBuffer();
try {
Socket socket = new Socket(host, port);
socket.setSoTimeout(20000);
BufferedReader bufferedreader = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
DataOutputStream dataoutputstream = new
DataOutputStream(socket.getOutputStream());
dataoutputstream.writeBytes(outbound.toString());
int j;
while((j = bufferedreader.read()) >= 0) {
char c = (char)j;
stringbuffer.append(c);
}
bufferedreader.close();
dataoutputstream.close();
} catch(SocketException e) {
System.out.println(e);
} catch(UnknownHostException e) {
System.out.println(e);
} catch(IOException e) {
System.out.println(e);
}
return stringbuffer.toString();
}
}
-----Original Message-----
From: Tim Nicholson [mailto:[EMAIL PROTECTED]]
Sent: 26 September 2002 16:08
To: JDJList
Subject: [jdjlist] is this the sort of code you deal with "in the real
world" ?
IS this the sort of code you deal with in the real world ?
If so, then my deepest fears really are true -- that java in the real world
may be a little too difficult for me to handle.
And that's really concerning.
----- Original Message -----
From: "Walter Van Eetvelt" <[EMAIL PROTECTED]>
To: "JDJList" <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 11:53 PM
Subject: [jdjlist] Re: /
Jim,
I think you're on the wrong list. Your problem does not seem to be
Java, but you seem to be missing beginners knowledge.
Get a book for novice programmers and start experimenting with the
code....
And don't look at the code of experienced programmers...
....
package com.buyformetals.categorytemplates;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.ResourceBundle;
import java.util.PropertyResourceBundle;
public class CatalogParserResources
{
private final static String propertiesFilename = "CatalogParser";
private static boolean initialized = false;
public static String PROTOCOL = null;
public static String HOST = null;
public static String OUTPUT_DIRECTORY = null;
public static String OUTPUT_PATH = null;
public static String OUTPUT_URL_PREFIX = null;
public static URL PRODUCT_CATALOG_2_CHECKLIST_XSL = null;
public static URL PRODUCT_CATALOG_2_INTERNAL_XSL = null;
public static URL CHECKLIST_2_FULL_REPORT_XSL = null;
public static URL CHECKLIST_2_PARTIAL_REPORT_XSL = null;
public static URL INTERNAL_2_DML_XSL = null;
public static URL INTERNAL_2_DBLOAD_PART_1_XSL = null;
public static URL INTERNAL_2_DBLOAD_PART_2_XSL = null;
public static URL INTERNAL_2_DBLOAD_UNINSTALL_XSL = null;
public static String JDBC_DRIVER = null;
public static String JDBC_CONNECTION_SID = null;
public static String JDBC_CONNECTION_USER = null;
public static String JDBC_CONNECTION_PASSWORD = null;
public static String SQL_STATEMENT_UOM = null;
public static String SQL_STATEMENT_LDD = null;
public static void init()
{
if (initialized)
return;
// Retrieve information from properties file
PropertyResourceBundle prop = (PropertyResourceBundle)
ResourceBundle.getBundle(propertiesFilename);
PROTOCOL = prop.getString("PROTOCOL");
HOST = prop.getString("HOST");
String appUrl = prop.getString("APPLICATION_URL");
if (appUrl.charAt(appUrl.length()-1) != '/')
appUrl = appUrl + "/";
String xslUrlPrefix = appUrl + prop.getString("XSL_DIRECTORY");
if (xslUrlPrefix.charAt(xslUrlPrefix.length()-1) != '/')
xslUrlPrefix = xslUrlPrefix + "/";
OUTPUT_DIRECTORY = prop.getString("OUTPUT_DIRECTORY");
OUTPUT_URL_PREFIX = appUrl + OUTPUT_DIRECTORY;
if (OUTPUT_URL_PREFIX.charAt(OUTPUT_URL_PREFIX.length()-1) != '/')
OUTPUT_URL_PREFIX = OUTPUT_URL_PREFIX + "/";
File outputDir = new
File(prop.getString("APPLICATION_PATH"),prop.getString("OUTPUT_DIRECTORY
"));
if (! outputDir.exists())
outputDir.mkdir();
OUTPUT_PATH = outputDir.getPath();
try
{
PRODUCT_CATALOG_2_CHECKLIST_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_PRODUCT_CATALOG_2_CHECKLIST"));
PRODUCT_CATALOG_2_INTERNAL_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_PRODUCT_CATALOG_2_BFM_INTERNAL"));
CHECKLIST_2_FULL_REPORT_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_CHECKLIST_2_FULL_REPORT"));
CHECKLIST_2_PARTIAL_REPORT_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_CHECKLIST_2_PARTIAL_REPORT"));
INTERNAL_2_DML_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_BFM_INTERNAL_2_DML"));
INTERNAL_2_DBLOAD_PART_1_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_BFM_INTERNAL_2_DBLOAD_CLASSES"));
INTERNAL_2_DBLOAD_PART_2_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_BFM_INTERNAL_2_DBLOAD_EVVS"));
INTERNAL_2_DBLOAD_UNINSTALL_XSL = new
URL(PROTOCOL,HOST,xslUrlPrefix +
prop.getString("XSL_BFM_INTERNAL_2_DBLOAD_UNINSTALL"));
}
catch (MalformedURLException e)
{
System.err.println("Exception creating XSL URL's: " +
e.getMessage());
}
JDBC_DRIVER = prop.getString("JDBC_DRIVER");
JDBC_CONNECTION_SID = prop.getString("JDBC_CONNECTION_SID");
JDBC_CONNECTION_USER = prop.getString("JDBC_CONNECTION_USER");
JDBC_CONNECTION_PASSWORD =
prop.getString("JDBC_CONNECTION_PASSWORD");
SQL_STATEMENT_UOM = prop.getString("SQL_STATEMENT_UOM");
SQL_STATEMENT_LDD = prop.getString("SQL_STATEMENT_LDD");
initialized = true;
}
}
Walter
-----Original Message-----
From: Tim Nicholson [mailto:[EMAIL PROTECTED]]
Sent: donderdag 26 september 2002 16:29
To: JDJList
Subject: [jdjlist] Re: /
At present I am *stuck* so I don't see my understanding getting any
better
!!!!
If, like I have done before, I can see a solution, I can then learn from
that solution and be able to solve problems that come up that are of a
similar nature. That is what I am thinking of.
----- Original Message -----
From: "Mark E. Zawadzki" <[EMAIL PROTECTED]>
To: "JDJList" <[EMAIL PROTECTED]>
Sent: Wednesday, September 25, 2002 9:11 PM
Subject: [jdjlist] /
> Convoluted answers ??? Joseph's answer addresses the implicit goal of
the
exercises provided -
> divide and conquer. Or to quote (IMSM) Henry Ford - no job is
impossible
if you break it down
> into small enough steps.
>
> And to answer Tim's second Q - a programmer is a translator between
the
human world view and the
> computer's world view of and/or gates; this, of course, involves
abstraction and decomposition.
>
> P.S. Tim - The greater effort you make to solve these problems on your
own, the greater will be
> you reward of understanding.
>
>
>
> --- H Shankaranarayanan <[EMAIL PROTECTED]> wrote:
> > There it starts again. If people can answer straight on this list it
would be
> > really great. Why such convoluted answers?
> >
> > And am sure Alan this is of no interest to anyone asking questions
be it
on any
> > topic. Its just going to make them think twice before asking a
question
down the
> > line.
> >
> > -----Original Message-----
> > From: Tim Nicholson [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 25, 2002 4:18 AM
> > To: JDJList
> > Subject: [jdjlist] what is it like to be a programmer "in the real
> > world" ?
> >
> >
> > And to Joseph or anyone else who would like to answer:-
> >
> > Can you possibly tell me what it is like to be a programmer (in I
assume
the
> > Java language) in the real world ? What I mean really by that is,
what
sort
> > of code do you write in your job ? I assume you are working as a
computer
> > programmer ?
> >
> > So what sort of code do you produce and work with in your job ? And
is
this
> > difficult code ? Would I find it difficult to understand and work
with ?
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Joseph B. Ottinger" <[EMAIL PROTECTED]>
> > To: "JDJList" <[EMAIL PROTECTED]>
> > Sent: Wednesday, September 25, 2002 8:12 PM
> > Subject: [jdjlist] Re: two exercises I am trying to solve at the
moment....
> >
> >
> > > RE: [jdjlist] Re: J2MEWell, Tim, the first step is to read the
suggestions
> > > made by your coursework. Start small; write functions that do the
simple
> > > stuff first. Break the problems down (although most of the work
has
been
> > > done for you already.) Man, these questions have gotten easier
since
*I*
> > was
> > > in grade 9.
> > >
> > > ----- Original Message -----
> > > From: Tim Nicholson
> > > To: JDJList
> > > Sent: Wednesday, September 25, 2002 4:09 AM
> > > Subject: [jdjlist] two exercises I am trying to solve at the
moment....
> > >
> > >
> > > Hi everyone again,
> > >
> > > this is in addition to the previous email that I sent but this is
on a
> > > rather different topic.
> > >
> > > I am trying to work through some problems/exercises and I was
wondering if
> > > anyone might be able to suggest how I might be able to solve these
> > problems
> > > ?
> > >
> > > Like I said before, this email is on a different topic to the
email
that I
> > > sent before.
> > >
> > > The 1st problem I was wondering if anyone could help me on is as
follows
> > :-
> > >
> > >
========================================================================
> > >
> > > Design and implement a program that allows the user to input a
number
in
> > any
> > > base (2..16) as a string of digits (0..9, A..F) and the base that
the
> > number
> > > is in and displays the value in decimal of the input number.
> > > Your program must have two function methods that respectively
return:
> > > the value of one digit character; and
> > > the value of a whole string of digits in a given base.
> > > Hint: The first of those functions makes it easier to write the
second.
> > > Your program may have a BreezySwing or text-only interface
> > >
> > >
========================================================================
> > >
========================================================================
> > > And the second one is like this :-
> > >
=======================================================================
> > > Write a program that allows the user to input any int value and
outputs
> > that
> > > number in words.
> > > Examples:
> > > inputoutput
> > > 0zero
> > > 3three
> > > 13thirteen
> > > 23twenty-three
> > > 223223two hundred and twenty-three thousand, two hundred and
twenty-three
> > > 223223223two hundred and twenty-three million, two hundred and
> > twenty-three
> > > thousand, two hundred and twenty-three
> > > >2147483647two billion, one hundred and forty-seven million, four
hundred
> > > and eighty-three thousand, six hundred and forty-seven
> > > -1minus one
> > >
> > > Your program must have three function methods that respectively
return:
> > > a value between 1 and 9 in words;
> > > a value between 1 and 999 in words; and
> > > any int value in words.
> > > Hint: The first of those functions makes it easier to write the
second
and
> > > writing the second will help write the third.
> > > Good solutions may have even more functions.
> > >
========================================================================
=
> > >
========================================================================
> > > I really don't have a clue how to solve these so any help as to
what
sort
> > of
> > > algorithm and java code implementation that I could use, would be
very
> > much
> > > appreciated.
> > >
> > >
> > > To change your JDJList options, please visit:
> > > http://www.sys-con.com/java/list.cfm
> > >
> > > To change your JDJList options, please visit:
> > http://www.sys-con.com/java/list.cfm
> > >
> >
> >
> >
> > To change your JDJList options, please visit:
> > http://www.sys-con.com/java/list.cfm
> >
> >
> > To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
>
>
> =====
>
> Mark Zawadzki Performance Engineer/DBA/Programmer extraordinaire'
[EMAIL PROTECTED] [EMAIL PROTECTED]
>
> "Democracies die behind closed doors," - Judge Damon Keith
>
>
> __________________________________________________
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
>
> To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
To change your JDJList options, please visit:
http://www.sys-con.com/java/list.cfm
To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm