Results 1 to 3 of 3
- 12-04-2010, 06:27 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
- 12-06-2010, 06:49 PM #2
Senior Member
- Join Date
- Nov 2010
- Location
- Delhi
- Posts
- 135
- Blog Entries
- 1
- Rep Power
- 0
Code below might be of any help to you:
Java Code:import java.io.ByteArrayOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class DateDifference { public static void main(String[] args) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); String s = "Put this string in ByteArrayOutputStream"; byte buf[] = s.getBytes(); // write the bytes in ByteArrayOutputStream byteArrayOutputStream.write(buf); // Call for printing contents printStreamContents(byteArrayOutputStream); // write the contents to file writeToFile(byteArrayOutputStream); } private static void printStreamContents(ByteArrayOutputStream baos){ // printing the contents System.out.println("ByteArrayOutputStream contents: " + baos.toString()); } private static void writeToFile(ByteArrayOutputStream baos) throws IOException{ OutputStream outputStream = new FileOutputStream("example.txt"); baos.writeTo(outputStream); outputStream.close(); } }
- 12-14-2010, 08:47 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 8
- Rep Power
- 0
Thank you for your reply. I have tried with .toString method. But stilll ... Can advise on below?
Below is my scenario:
I wish to display the sound data value (numeric) at the output panel while i am capturing sound from my microphone.
The program is included with the playback features which is not included in this topic.
For this purpose, i have a temporary buffer to store the captured sound data temporary from audio dataline.
The result that i got is a bunch of unknown character displayed on the output panel. I have gon through the method description for byteArrayOutputStream.toString(). ByteArrayOutputStream (Java 2 Platform SE v1.4.2)Java Code:class CaptureThread extends Thread{ byte tempBuffer[] = new byte[10000]; public void run(){ byteArrayOutputStream = new ByteArrayOutputStream(); //Read data from the internal buffer of the data line. int cnt = targetDataLine.read(tempBuffer, 0, tempBuffer.length); if(cnt > 0){ //Save data in output stream object. byteArrayOutputStream.write(tempBuffer, 0, cnt); System.out.println(byteArrayOutputStream.toString()); }//end if byteArrayOutputStream.close(); }
Suppose it shows the content of buffer.
The purpose i wish to display the content because i wish to find out the way to retrieve the sound data for Fast Fourier transform.
Like MATLAB, the sampled sound data (x) can be display with such function
[x,fs,nb]=wavread("My_love.wav");
Hereby wish to have your advise how can i get do the same thing of displaying the sound data value with Java.
Please advise. Many thanks on correcting my mistake.
Similar Threads
-
how to display the retriewing data in gridview
By mahesh_mscit in forum AWT / SwingReplies: 0Last Post: 08-01-2009, 05:02 PM -
how to display data from oracle database?
By deru4jesus in forum JavaServer Faces (JSF)Replies: 0Last Post: 04-16-2009, 08:46 AM -
ByteArrayInputStream and ByteArrayOutputStream
By new_2_java in forum New To JavaReplies: 6Last Post: 07-31-2008, 10:02 PM -
Best GUI Element to Display Mass Data
By hannehomuth in forum Advanced JavaReplies: 3Last Post: 07-29-2008, 11:18 PM -
how to display data in Jtree
By paty in forum New To JavaReplies: 1Last Post: 07-24-2007, 12:28 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks