How to store a mid file in byte[ ]

I used this method to store the song but it does not seem to be working.
public byte[] getSongAs_ByteArray() {
    byte[] data = new byte[50848];
    InputStream in = null;
    try {
      HttpConnection connection = null;
      Connector.open("http://www.ziyaaf.com/XML/girl.mid ");
      connection = (HttpConnection) Connector.open(
          " http://www.ziyaaf.com/XML/girl.mid");
          in = connection.openInputStream();
           DataInputStream dis = new DataInputStream(in);
      dis.readFully(data);
      in.close();
    catch (IOException ex) {
      System.out.println("::" + ex);
    return data;
But if i use this method it works
public byte[] loadSong() {
    byte[] data = new byte[50848];
    try {
      Class c = this.getClass();
      InputStream is = c.getResourceAsStream(" girl.mid");
      DataInputStream dis = new DataInputStream(is);
      dis.readFully(data);
      is.close();
    catch (IOException ioe) {
      ioe.printStackTrace();
    return data;
But i want to load the song from a remote location
And this is the method i used to play the mid file.
ByteArrayInputStream b = new ByteArrayInputStream(getSongAs_ByteArray());
    try {
      player = Manager.createPlayer(b,
                                    "audio/midi");
      player.start();
    }

onnector.open("http://www.ziyaaf.com/XML/girl.mid
connection = (HttpConnection) Connector.open(
" http://www.ziyaaf.com/XML/girl.mid");
Firstly, you call open twice, you don't check for http errors, and on the first URL you have a space after the ".mid", and on the second URL your have a space before "http".
And never ever use fixed size byte arrays!
And why load the midi file in memory when you can play it directly from stream (specially if you read from file)?

Similar Messages

  • How to store the flat file data into custom table?

    Hi,
    Iam working on inbound interface.Can any one tell me how to store the flat file data into custom table?what is the procedure?
    Regards,
    Sujan

    Hie
    u can use function
    F4_FILENAME
    to pick the file from front-end or location.
    then use function
    WS_UPLOAD
    to upload into
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_FILENAME'   "Function to pick file
        EXPORTING
          field_name = 'p_file'     "file
        IMPORTING
          file_name  = p_file.     "file
      CALL FUNCTION 'WS_UPLOAD'
       EXPORTING
         filename                       = p_file1
        TABLES
          data_tab                      = it_line
    *then loop at it_line splitting it into the fields of your custom table.
    loop at it_line.
              split itline at ',' into
              itab-name
              itab-surname.
    endloop.
    then u can insert the values into yo table from the itab work area.
    regards
    Isaac Prince

  • How to store an Excel file in InfoPath for users to edit

    Hello,
    I need an example on how to store an Excel file within InfoPath 2010 so that every time a user opens the InfoPath form they can make changes and can save as part of the form. The next user opens the form and another Excel files (blank) where they make changes and
    saves. Thanks

    Streamlining this would require a bit of custom work I imagine. However if you don't mind giving the users some extra clicks, there are probably a few ways to get the job done.
    You could upload the excel file to SharePoint, make sure it's read-only and link to it within the InfoPath form. Then the process would be that users open the InfoPath form, fill it out, download the excel doc to their desktops and fill it out, and then
    attach it to the IP form.
    Or you could set up a separate, sister library where the New Item defaults to your Excel template. Then from within the InfoPath form you could have a hyperlink that creates the new item, saving it to the library. The caveat here is finding a way to link
    to the two items together with a unique identifier. The benefit though is being able to browse and interact with Excel docs independent of the forms they are attached to, if necessary.

  • How to store the zip file in oracle table?

    hi,
    How to store the zip file in oracle table ?
    is it possible to unzip and read the file ?
    Thanks
    Rangan S

    SQL> DESC BLOB_TABLE;
    Name Type Nullable Default Comments
    A INTEGER Y
    B BLOB Y
    SQL> INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'))
    ORA-00904: "BLOB": invalid identifier
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'))
    ORA-00907: missing right parenthesis
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'))
    ORA-01465: invalid hex number
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));

  • Multiple MailAttachment  to File   -   How to store as multiple files ?

    Hi Friends ,
                      Can you please tell me  How to Store as Multiple files which i read as attachements  from Mail Sender Adapter .
                         In My scenario i can able to bring the Multiple attachement in the Paylod using PaylodSwapBean .<b> I wan to store these attachements to a file system.</b>   ie. Whatever attachements i am reading i have to store in a file .             
               For eg., In my scenario i have designed the Data Type as DT_Test--> Row --- > Details .
                     Details can able to hold each line of Each File . One file contains multiple Line data .
                   <b>  If i use Message Transform Bean</b> , first attachement only getting Tranformed rest of them as it is . Not getting tranformed to required format.
                     Please give some suggestions !
    Regards .,
    V.Rangarajan

    Oops didn't observe abt the message transform bean usage... .....
    check with these
    3.2.3 Changing the Name and Type of the Payload................................. 6
    3.2.4 Sending a Mail with Attachment ...................................................... 7
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9e6c7911-0d01-0010-1aa3-8e1bb1551f05
    SAP Note 793922
    http://help.sap.com/saphelp_nw04s/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
    <b>Cheers,
    *RAJ*<b>

  • How to store character in file and display result on front panel

    hi
    currently i m working on FPGA project.i want to aquired data from FPGA board.i want to know about how to store character to file and contineous display each character on front panel in string format.
    i have complete up to character display on front panel but only single character display when i want all character in string format.
    Solved!
    Go to Solution.

    I don't see how this question is at all related to Digital I/O but it sounds like you just need a shift register with the concantanate string function.

  • How to store preferences in file system on Windows?

    I have 2 questions related to preferences using.
    1. How to store preferences in file system (not in registry) on Windows? I see file system implementation of Preferences (java.util.prefs.FileSystemPreferences). But this implementation is linux-specific (use native methods). Does universal implementation exist?
    2. How to store custom files in preferences? I need to store some user-specific files (XML files, for example) somewhere. These files are naturally user preferences. So my idea is to store it using Preferences. But it seems like there is no such posibility in standard preferences. I believe many peoples have the same problem. Does anyone have solution?
    Please help me!
    Thank you in advance.

    Preferences is supposed to keep all this data
    handling away from you, so you shouldn't bother. If
    you'd like to write a file, just write a file. You
    could create a "Settings" object and serialize it.I understand your reasonings. But unfortunately I have requirements to use file system preferences both on Linux and Windows. My bosses think there are many problems because of registry. Don't ask what problems, they didn't say. I cannot change their requirements. I must to implement it.
    Maybe somebody already solved this proplem. I will very grateful for help.
    Once again: simply write and read a custom file. Why
    do you use Preferences at all costs when they don't
    do what you want to?I have requirements to implement saving of files in the same manner as saving of preferences. It may be different code from Preferences. But it will be the best to have the same code if it possible.
    Any way I believe the need to save user-specific files as preferences is quite widespread.

  • Hey guys, my question is how can I export midi files from new garageband 10/ 2013? Thanks

    Hey guys, my question is how can I export midi files from new garageband 10/ 2013? Thanks

    77music wrote:
    how can I export midi files from new garageband 10/ 2013?
    unfortunately, like the previous 6 versions of GB, MIDI export is not supported. you would need to open the file in Logic in order to do that

  • How to store a JSP file in the SAP Application server ?

    Hello All,
    My reqt. is as follows :
    1. I need to store a JSP File on the SAP Application server .
    How can I do this ?
    2. I want to call the uploaded jsp file from the server and call this jsp from abap to view the result of it .
    How can I achieve this ?
    First of all is this possible ?
    Regards,
    Deepu.K

    Hello Mike,
    Thanks for ur reply.
    I've imported the JSP as a mime object into the BSP.
    Now I've created the page to show that Mime Object as an image.
    But nothing is coming as an output.
    But then,there is an option for that mime object. i.e when I right click on the mime object there is an option called " convert to BSP".
    I selected that option and it created a view in my BSP .( My BSP is a page with flow logic application )
    Now how should i make this view to be an output ?
    I guess this shud be posted in the BSP Forum ...but still taking a chance here :)-
    Regards,
    Deepu.K

  • How to store a word file in MS SQL server

    Hi,
    Am new to java, I want to store a Word File into MS SQL Server, pls tell me how to do this.
    What should be Data type I should choose in the MS SQL Server.
    rgds
    Ravi Bharathi

    You will have to simply load the file as a chunk of binary data in a blob (Binary Large Object) type column.
    In MS SQL Server the blob type is known as 'Image'

  • How to store a text file in a hash table in C#?

    I am fairly new to c#. I am creating a console application project for practice. I am supposed to create a program that reads a text file (it's a poem), store it in a hash table, have two different sorts, and unhash the table. I managed to get the poem read
    by using streamwriter, but now I am not sure how to store it in a hash table. 
    I'm not sure if I am doing this hash table correct, but I made my hash table like this to store the text file: 
          Hashtable hashtable = new Hashtable();
                hashtable[1] = (@"C:\\Documents\\Datastructures\\Input\\Poem");

    Hi,
    Hashtable in C# represents a collection of key/value pairs which maps keys to value. Any non-null object can be used as a key but a value can. We can retrieve  items from hashTable to provide the key . Both keys and values are Objects.
    Here is a sample about Hashtable,
    Hashtable weeks = new Hashtable();
    weeks.Add("1", "SunDay");
    weeks.Add("2", "MonDay");
    weeks.Add("3", "TueDay");
    weeks.Add("4", "WedDay");
    weeks.Add("5", "ThuDay");
    weeks.Add("6", "FriDay");
    weeks.Add("7", "SatDay");
    //Display a single Item
    MessageBox.Show(weeks["5"].ToString());
    //Search an Item
    if (weeks.ContainsValue("TueDay"))
    MessageBox.Show("Find");
    else
    MessageBox.Show("Not find");
    //remove an Item
    weeks.Remove("3");
    //Display all key value pairs
    foreach (DictionaryEntry day in weeks)
    MessageBox.Show(day.Key + " - " + day.Value);
    >>I managed to get the poem read by using streamwriter, but now I am not sure how to store it in a hash table
    Hashtable hashtable = new Hashtable();
    hashtable[1] = (@"C:\\Documents\\Datastructures\\Input\\Poem");
    But follow your scenario above, you just store a string path to hashtable not a file.
    About saving data to a file, you can use the following code.
    // Write the string to a file.
    System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt");
    file.WriteLine(lines);
    file.Close();
    Best wishes!
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to store a signature file in database oracle 8.0

    hai,
    please send a sample code how to store a signature stored in a flat file a.gif,b.tif into oracle database please send me the script to [email protected]
    please help me any one

    Hi,
    Read the Articles in the Documentation regarding BFILE. There is a Beautiful example on the docs.
    You can also BLOBS to store these images in the database.
    Best of Luck.
    regards,
    Ganesh R

  • How to store my mp3 files into my database

    Hello,
    I am having some trouble with a database i am creating to store my mp3 files. I have created the following sql statement so far using what research i did on the subject.
    CREATE TABLE music
    ( Artist CHAR(30),
    NameOfSong CHAR(30),
    Song BLOB);
    But i have no idea how to do a INSERT statement for the BLOB datatype. I am trying to use a location on my hard drive to upload the song to the table. All help is welcomed.
    Thank you,

    http://forums.oracle.com/forums/search.jspa?threadID=&q=insert+blob&objID=f75&dateRange=all&userID=&numResults=15
    Message was edited by:
    jeneesh

  • How to store streaming video file

    Hello friend
    Am streaming video file with use of VLC player,while streaming the video file i want to receive and store the video file.

    You first need to know, how VLC streams the data. If you know that, you have to write client code, which can connect to VLC and receive packets. The next step would be to analyze the packets and extract the video/ausio data from it and write it to a file. But all depends on what video format is streamed with which protocol.

  • Suggestion for Music Store(sell midi files for garange band & sheet music)

    Sell MIDI files of songs sold on the music store and sheet music with lyrics.

    http://www.apple.com/feedback/itunes.html

Maybe you are looking for

  • Issue with using formatted date value column in order by clause...

    Hi, 1) Through a function I am listing all the months in a year. like JAN-2007, FEB-2007,MAR-2007...... 2) i am comparing these values against a date value column in a table. And if there are no values in a particular period it will return a null val

  • My backed up apps will not restore back on my iPod touch how do I do that?

    I just updated  my iPod touch 4 to the iOS 5 version and when i turned it back on it had all the new features, all my previous pictures, mail, music, contacts, and videos but  it did not have ANY of my apps I downloaded to my iPod touch when it was j

  • Where can i buy macbook(13 inch) video flex cable?

    My macbook's (13 inch, 2008year) screen is not working. But i can connect to an external monitor. So I think something wrong with my video flex cable was broken. where can i buy the cable? THanks.

  • Imac 24" dvd-drive doesnt show inserted DVDs randomly, only after reboot (?

    hi i am very aware of this problem as my powerbook G4 had the same issue, although its not a big issue i am worring about. when i insert a DVD sometimes, lets say a commercial Movie DVD, an older burned DVD from 2002 or 2005 or even 2006, my brand ne

  • MP3 header reading

    Hi. I am making a simple music player and would like to be able to read the header of the MP3 file. I have searched somewhat on the internet but I have found no solution, yet. I found articles about getting the MP3 file into a byte[] and then read th