@Indicator Veritatis
code for mminstream that u r asking for. :
private final BluetoothSocket mmSocket;
private final InputStream mmInStream;
private final OutputStream mmOutStream;
public ConnectedThread(BluetoothSocket socket) {
Log.d(TAG, "create ConnectedThread");
mmSocket = socket;
InputStream tmpIn = null;
OutputStream tmpOut = null;
// Get the BluetoothSocket input and output streams
try {
tmpIn = socket.getInputStream();
tmpOut = socket.getOutputStream();
} catch (IOException e) {
Log.e(TAG, "temp sockets not created", e);
}
mmInStream = tmpIn;
mmOutStream = tmpOut;
}
public void run() {
Log.i(TAG, "BEGIN mConnectedThread");
byte[] buffer = new byte[4096];
int bytes = 0,mb;
String file_name;
long file_length;
// Keep listening to the InputStream while connected
while (true) {
try {
// Read from the InputStream
Log.d(TAG, "file creating");
FileOutputStream fos = new
FileOutputStream("sdcard/abc.txt");
BufferedOutputStream bos = new BufferedOutputStream(fos);
/*BufferedReader nbr=new BufferedReader(new
InputStreamReader(mmInStream));
file_name=nbr.readLine();
Log.d(TAG, file_name);
file_length= Long.parseLong(nbr.readLine());
Log.d(TAG, "file length withdrawn");
double nosofpackets = Math.ceil(( (int)file_length)/4096);*/
//for(double i=0; i<nosofpackets; i++)
//for(double i=0; i<4; i++)
// {
//bytes = (Integer) null;
//Log.d(TAG, "begin inputstream");
// bytes = mmInStream.read(buffer);
Log.d(TAG, "data incoming");
//System.out.println(bytes);
Log.d(TAG, "begin file writing");
//bos.write(buffer, 0,buffer.length);
while((bytes = mmInStream.read(buffer))>0){
Log.d(TAG, "data is there for writing");
bos.write(buffer);}
//}
// Send the obtained bytes to the UI Activity
mHandler.obtainMessage(BluetoothChat.MESSAGE_READ,
bytes, -1, buffer)
.sendToTarget();
} catch (IOException e) {
Log.e(TAG, "disconnected", e);
connectionLost();
break;
}
}
--
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
---
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.