static void captureAudioFromLine(DataLine line, AudioFormat audioFormat) { if (!line instanceof TargetDataLine) fail(getClassName(line)); TargetDataLine tdl = cast line; tdl.open(audioFormat); tdl.start(); int total = 0, n; byte[] buf = new byte[1024]; while (total < 1024*10 && (n = tdl.read(buf, 0, l(buf))) > 0) { total += n; print("Bytes read from line: " + total); } tdl.close(); }