I have a byte file that contains tcp packets. I want to use sockets to read those packets.
so is it possible to use Sockets to read this file without connection ?
FileInputStream mInStream = new FileInputStream("file path").
byte[] buffer = new byte[1024];
// Keep listening to the InputStream
while (true) {
try {
bytes = mInStream.read(buffer, 0, buffer.length);
}catch {}
}
No, but you can use a FileInputStream and read bytes from the files like the following snippet:
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream("path_to_file").
while((fis.read(buffer) != -1)
// do something with the bytes readed