[
https://issues.apache.org/jira/browse/FLINK-2490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14693224#comment-14693224
]
ASF GitHub Bot commented on FLINK-2490:
---------------------------------------
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
```
> Remove unwanted boolean check in function
> SocketTextStreamFunction.streamFromSocket
> -----------------------------------------------------------------------------------
>
> Key: FLINK-2490
> URL: https://issues.apache.org/jira/browse/FLINK-2490
> Project: Flink
> Issue Type: Bug
> Components: Streaming
> Affects Versions: 0.10
> Reporter: Huang Wei
> Priority: Minor
> Fix For: 0.10
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)