• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OutputStreamReader

 
Desmond Connor
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 java.net.*; //net
import java.io.*; //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
Wanderer
Sheriff
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic