質問編集履歴
1
調べてみると、ソケット接続にBufferedInputStreamは向いていないとのことなので、InputStreamを使用するよう変更、それに伴いwhile文も変更しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,7 +66,7 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
-
import java.io.
|
69
|
+
import java.io.InputStream;
|
70
70
|
|
71
71
|
import java.io.BufferedWriter;
|
72
72
|
|
@@ -216,15 +216,19 @@
|
|
216
216
|
|
217
217
|
private void StartPick() {
|
218
218
|
|
219
|
-
try (BufferedInputStream bufferedInputStream =
|
220
|
-
|
221
|
-
|
219
|
+
try (InputStream inputStream = btSocket.getInputStream();
|
220
|
+
|
222
|
-
|
221
|
+
OutputStream outputStream =
|
222
|
+
|
223
|
-
|
223
|
+
openFileOutput(fileName, Context.MODE_PRIVATE);
|
224
|
+
|
224
|
-
|
225
|
+
OutputStreamWriter outputStreamWriter =
|
226
|
+
|
225
|
-
|
227
|
+
new OutputStreamWriter(outputStream, "UTF-8");
|
228
|
+
|
226
|
-
|
229
|
+
BufferedWriter bufferedWriter =
|
230
|
+
|
227
|
-
|
231
|
+
new BufferedWriter(outputStreamWriter)) {
|
228
232
|
|
229
233
|
|
230
234
|
|
@@ -238,12 +242,22 @@
|
|
238
242
|
|
239
243
|
|
240
244
|
|
245
|
+
while (true) {
|
246
|
+
|
241
|
-
|
247
|
+
int len = inputStream.read(buffer);
|
248
|
+
|
249
|
+
if (len == -1) {
|
250
|
+
|
251
|
+
break;
|
252
|
+
|
253
|
+
}
|
242
254
|
|
243
255
|
outputStream.write(buffer, 0, len);
|
244
256
|
|
245
257
|
}
|
246
258
|
|
259
|
+
|
260
|
+
|
247
261
|
String readData = outputStream.toString();
|
248
262
|
|
249
263
|
if (readData.trim() != null && !readData.trim().equals("")) {
|