Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/992#issuecomment-130237642
> 1.In using StringBuilder, does it mean that we should use
BufferedReader.readLine() instead of BufferedReader.read()?
Reading by character is the way to go if we use a custom `delimiter`. If
our delimiter was `\n` then it would be ok to read entire lines.
> Could you tell me how to make the BufferedReader.read() return -1? I
tried many ways that all filed.
Ok :) Here is a minimal working example where `read()` returns `-1`:
```java
public static void main(String[] args) throws IOException {
ServerSocket socket = new ServerSocket(12345);
final SocketAddress socketAddress = socket.getLocalSocketAddress();
new Thread(new Runnable() {
@Override
public void run() {
Socket socket = new Socket();
try {
socket.connect(socketAddress);
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader bufferedReader = new
BufferedReader(new InputStreamReader(socket.getInputStream()));
System.out.println((bufferedReader.read()));
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
Socket channel = socket.accept();
channel.close();
}
```
Output:
```
-1
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---