Two Laptop Bag
The moose likes I/O and Streams and the fly likes OutputStreamReader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "OutputStreamReader" Watch "OutputStreamReader" New topic


Desmond Connor

Joined: Feb 14, 2004
Posts: 1
hello I was wondering if someone could help me I am new to the scene and I have to create a client, for some reason when I compile it does not like my OutputStreamReader I would be very grateful if someone could help me
this is my code:
import*; //net
import*; //io
public class client{
public static void main (String args[]) throws IOException{
Socket soc = new Socket ("localhost", 1010);
System.out.println ("requesting data");
BufferedReader bin = new BufferedReader (new InputStreamReader (System.out));
String portnum = bin.readLine();
int port = Integer.parseInt (portnum);
while (true) {
Socket conn = new Socket ("localhost",1010);
BufferedReader fromserver = new BufferedReader (new InputStreamReader (conn.getOutputStream()));
String Datatoserver = (" ");
DataOutputStream toserver = (new DataOutputStream (conn.getOutputStream()));
toserver.writeBytes (Datatoserver+"\n");

String data = fromserver.readLine();
System.out.println (" ");
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
Possibly that's because there's no such thing as an OutputStreamReader. You can have an InputStreamReader, or a OutputStreamWriter. If you use an InputStreamReader, the thing it reads should be... well... an InputStream. Not an OutputStream.

"I'm not back." - Bill Harding, Twister
I agree. Here's the link:
subject: OutputStreamReader
jQuery in Action, 3rd edition