• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

wav file serialization?

 
Trelan Hylton
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should i serialize a wav file before using it reading it. if so how do i do that.
i have a file in the directory that is in wav format and i want to read it into my program. what file stream do i use?
i have tried this code so far : 2 classes.
import java.io.*;
import java.util.*;

class Tester implements Serializable{
Object myFile;
public Tester getTest()
{
return (Tester)myFile;
}
public void setTest(Object myFile)
{
this.myFile = myFile;
}

}
and the one that reads the object

import java.io.*;
import java.util.*;

public class ObjectFromDisk{
public static void main(String []arg)
{
try{
FileInputStream fi = new FileInputStream("connect.wav");
ObjectInputStream oi = new ObjectInputStream(fi);
Tester tes = (Tester) oi.readObject();
System.out.println("I hope this works");
oi.close();
}catch(Exception e){System.out.println("Error -- " + e.toString());
}
}
}

i keep getting this error however :
java.io.StreamCorruptedException : invalid stream header.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic