import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

public class AudioStreamResetTest {
	
	
	static class NewAudioStream
	{
		private AudioInputStream ais;
		private File file; 
		
		public NewAudioStream(File file) throws UnsupportedAudioFileException, IOException
		{
			this.file = file;		
			reopenStream();
		}
		
		public boolean isMarkSupported(){return true;}
		public void reset() throws UnsupportedAudioFileException, IOException
		{
			this.ais.close();
			reopenStream();
		}
		
		private void reopenStream() throws UnsupportedAudioFileException, IOException
		{
			this.ais = AudioSystem.getAudioInputStream(file);
		}
	}
	
	public static void main(String[] args)
	{
		File fileIn;
		BufferedInputStream  is = null;
		AudioInputStream ais = null;
		try {
			fileIn = new File("audio/1234.aif");
			is = new BufferedInputStream(new FileInputStream(fileIn));
			ais = AudioSystem.getAudioInputStream(is);			
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		
		System.out.println("FileInputStream mark supported? " + is.markSupported());
		System.out.println("AudioInputStream mark supported? " + ais.markSupported());
	}
	
	

}
