se hai un inputStream in genere funziona
while (IS.available != 0) {
IS.read();
}