English 中文(简体)
不能找到代用法
原标题:Cannot find symbol method getOutputStream()
  • 时间:2011-11-23 15:45:48
  •  标签:
  • java

在我的节目中,当我尝试使用这两种联系法时,它给我留下了错误,即“不能找到代号法来获得权宜之计”。 我对我做错做什么没有想法,这里是法典。

socket = new ServerSocket(6000);
socket.accept();

ObjectInputStream inputStream;
ObjectOutputStream outputStream;

outputStream = new ObjectOutputStream(socket.getOutputStream());
inputStream = new ObjectInputStream(socket.getInputStream());

我是否试图使用这种 t?

最佳回答

简单:ServerSocket don t 。 仅用“清单”袖珍语书写或读写是毫无道理的。

您应使用:

ServerSocket serverSocket = new ServerSocket(6000);
Socket socket = serverSocket.accept();

ObjectOutputStream outputStream =
    new ObjectOutputStream(socket.getOutputStream());
ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream());

说明如何实际做到使用 rel=“nofollow”><条码>-和S>>>。

各位说,你“不知道”你做错做什么:编辑们告诉你exactly。 您的错误做法——试图在<代码>上打上。 看到汇编者错误本应是“瓦doc图”(http://code>ServerSocket/)之后,你即刻第一个电话港,这本港将使你能够证实确实存在didn t

问题回答

ServerSocket s don t provide streams. Instead, they provide child Socket s once connections are made, and from those Socket s, you ll get your streams. So you need to assign a Socket s2 = to your socket.accept(), and use the streams from there.

rel=“nofollow”>。

你们需要接受以下联系:

Socket workingSocket = serverSocket.accept();

and then you ll find that the Socket class does have the method you re after.

服务器式自动取款机(OutputStream())和获得投入Stream(InputStream)成员。

rel=“nofollow”> 页: 1

and here s the tutorial





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...