Save stream to file

hi
would someone be kind to help me
i need to know how to to save stream to file
10x

use this code, could be helpful for understanding.
     final File resultFile = new File(resultFilePath) ;
     final FileOutputStream out = new FileOutputStream(resultFile) ;
     final PrintWriter writer = new PrintWriter(out) ;
     writer.write(resultBuffer.toString()) ;
     writer.close() ;
out.close() ;     
make sure of IO Exceptions ... this is just a code snippet, refactor it ...
Regards
Abhi

Similar Messages

  • Save streamed MP3 file?

    Our app includes a music player which streams MP3s from a server. We would like to be able to stream the MP3, and save it to a cache on disk once it has fully downloaded.
    I am using the load() method of the Sound class to stream the MP3 so that playback can begin before the file is fully downloaded. I can listen for the Event.COMPLETE event to indicate that the MP3 has finished downloading, but the Sound class offers no way to access the original file and save it to disk (the extract() method returns uncompressed sound data which is much too large to write to the disk).
    Is there any method to download an MP3 file that will allow us to stream the MP3 file as it is downloading, and save it to disk when the download is complete, without downloading it twice?

    Unless you can find an MP3 encoding library that could take the extract() data and convert it back with minimal effort, I think your only option is to save the mp3 using the File and FileStream classes. One thing you could try is to use a File object to download the file, and while it is downloading, you have the sound object play the data contents of the File object downloading the mp3. I just tried a quick test locally and it worked on my desktop. You will have to try it from an actual server to know how well it can work in that environment, but it is at least worth a shot.
    import flash.filesystem.File;
    import flash.filesystem.FileMode;
    import flash.filesystem.FileStream;
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.media.Sound;
    import flash.net.URLRequest;
    var file:File = File.applicationDirectory.resolvePath("gravity.mp3");
    file.addEventListener(ProgressEvent.PROGRESS, onProgressEvent);
    file.addEventListener(Event.COMPLETE, onFileLoadComplete);
    file.load();
    var sound:Sound;
    function onProgressEvent(e:ProgressEvent):void {
      if (sound == null) {
      file.removeEventListener(ProgressEvent.PROGRESS, onProgressEvent);
      sound = new Sound(new URLRequest(file.url))
      sound.play();
    function onFileLoadComplete(e:Event):void {
      file.removeEventListener(Event.COMPLETE, onFileLoadComplete);
      var saveFile:File = File.desktopDirectory.resolvePath("gravity2.mp3");
      var fs:FileStream = new FileStream();
      fs.open(saveFile, FileMode.WRITE);
      fs.writeBytes(file.data, 0, file.data.length);
      fs.close();
    What this code is doing is creating a File object with, in this case, a path to an MP3 in the same folder as the test FLA I created. This would be a path to your server stored MP3. Then you setup the event listeners for progress and complete. I used progress to know that the file had actually started to be downloaded to then trigger the initialization of my Sound object. Depending on someones network connection and the size of the MP3, it could be a good idea to use progress to know that the file has gotten X percentage done before trying to play the file.
    For testing purposes in my progress event, I just checked to see if the Sound object had been initialized yet, and if it hadn't then set sound equal to a new Sound object with the File.url property for the URLRequest() and then told it to play.
    Once the File object dispatched the complete event to indicate that the download finished, I created a new File object for the purpose of saving it to the filesystem using the FileStream class. Using FileStream to save the file allows for no user interaction to save the MP3.
    There may be better ways to handle my method, but I can't think of any at the moment. As far as I know, the second File object, which I named "saveFile", is required in order to actually save the downloaded MP3 object because Im not too familiar with File manipulation. The only downside I can think of is that you have a copy of the MP3 is memory and would need to null out the File object that loaded the MP3 to free up memory.

  • When I save a pages document as a pdf and then try to email the document, it loads as an application octet-stream dat file instead of a pdf. What's happening?

    When I save a Pages document as a pdf and then try to email the document, it loads as an application octet-stream dat file instead of a pdf and recipients can't open it. Some load correctly, but about half don't load as a pdf. What's happening?

    Hi mjmonck-
    Which email provider are you using? There are different solutions possible for different providers. Yahoo is having trouble with attachments, outside of any Firefox issue. I've seen a Google user fix this by manually adding the mail URL to their ad block program- which mistakenly perceived the webmail page as an advertisement.
    Hope this helps.

  • Can i save streaming audio to a file on my iMac?

    Is there a relatively easy way to save audio to the hard drive?  Most audio capture and editing software seems to have too many extra features and looks complicated? (this is my first Mac)  We would jst like to save an occasional file to replay later.  Thanks in advance, Pat

    Just found this reply to a similar question:
    True "streaming" media (served from streaming server protocols like RTSP) are not cached so you can only save a "link" to the file.  99.9% of Internet media isn't streamed. They download.
    Is it then possible to capture (with software) something we listen to on the Internet - cached or not? 

  • VLC doesn't save streaming audio to mp3 anymore

    I want to save streaming audio from the internet to my HDD in mp3 format while listening to it at the same time.  That worked fine when I did it with VLC, using the GUI.  To be specific, here are the settings that I used:
    VLC main menu: File>Open Network Stream>Open...Network>tick HTTP/HTTPS/FTP/MMS and enter the URL (http://vruk.sc.llnwd.net:12265) >under Advanced Options tick Stream/Save and click on Settings (opens Stream Output window)>Outputs, tick Play locally, tick File, click on Browse and enter filename and location for the stream saving file, i.e. /home/robert/vlcout.mp3>Encapsulation method, tick on Raw>Transcoding options, tick on Audio codec and select mp3>Bitrate 128 kb/s, Channels 2>OK, OK, to start recording. Stop or Quit VLC, to stop recording.
    Two days ago I upgraded VLC from v.0.8.5-9 to v.0.8.6a-4 (which also upgraded ffmpeg from v.20060920-1 to v.20070131-1), and now the above procedure isn't working anymore.  The stream isn't playing anymore over my speakers while the encoding supposedly is going on, the vlcout.mp3 file is empty (0B), and VCL gives me the following error messages:
    stream_out_transcode error: cannot find encoder ((null))
    stream_out_transcode error: cannot create audio chain
    main error: cannot create packetizer output (mpga)
    It looks as though VLC is failing to encode the stream to mp3.  The VLC documentation (see http://www.videolan.org/streaming-features.html) in a table of "possible output formats for the transcoding module" says that for mp3 audio "you have to compile ffmpeg with libmp3lame support."  Has the new ffmpeg v.20070131-1 (in extra) been compiled without mp3 support?  If so, why?  Apparently, the older version I was using last week supported mp3.
    libmp3lame is installed on my system.  There is a very recent alternative ffmpeg-svn-8218-1 pkgbuild in AUR that enables libmp3lame in the configure section of the build but when I try to install the package built that way it conflicts with ffmpeg v.20070131-1, and to remove the official ffmpeg v.20070131-1 I'd first have to remove a slew of other packages that depend on it.
    Is it possible to remove VLC v.0.8.6a-4 and ffmpeg v.20070131-1 and go back to the older versions that worked for me?  There was talk of a bug in ffmpeg in this forum at the end of January; what about it?
    What should I do?
    Robert
    Last edited by RobF (2007-03-14 16:25:51)

    I solved the problem for now by downgrading both vlc and ffmpeg to the earlier versions that I was using before.  Saving an audio stream in mp3 format is working again now.
    I believe there are problems with the current versions of both vlc and ffmpeg.
    1. vlc 0.8.6a doesn't seem to have ffmpeg enabled, i.e.
    $ vlc --list | grep ffmpeg
    VLC media player 0.8.6a Janus
    whereas with the older version I get
    $ vlc --list | grep ffmpeg
    VLC media player 0.8.5 Janus
      ffmpeg                FFmpeg audio/video decoder/encoder ((MS)MPEG4,SVQ1,H263,WMV,WMA)
      ffmpeg                FFmpeg chroma conversion
      ffmpeg                FFmpeg audio/video encoder
      ffmpeg                FFmpeg demuxer
      ffmpeg                FFmpeg video filter
      ffmpeg                FFmpeg crop padd filter
      ffmpeg                FFmpeg deinterlace video filter
    2. The current package ffmpeg v.20070131-1 in extra may not refer to various libraries correctly in its configure parameters.  E.g. in AUR there is an alternative pkgbuild ffmpeg-svn 8218-1 from 04-Mar-2007 in which the original configure parameters were replaced as follows:
    --enable-mp3lame --> --enable-libmp3lame
    --enable-vorbis --> --enable-libvorbis
    --enable-faac --> --enable-libfaac
    --enable-faad --> --enable-libfaad
    --enable-a52 --> --enable-liba52
    --enable-dts --> --enable-libdts
    Has the ffmpeg package in extra been compiled with mp3 support which is needed for the transcoding module of vlc to encode in mp3 format?  The alternative ffmpeg package in AUR conflicts with the ffmpeg package from extra, and I don't know how to tell the new vlc to use the alternative package instead of the one from extra. 
    Someone ought to look into this.
    Robert

  • Decode Base64 and save as binary file

    Hi there,
    I am using Adobe Air 1.5 with JavaScript and want to save a file to my hard
    drive. I get the data from a WebService via SOAP as a Base64 encoded string. A test-string is attached. When I try to decode it with
    the WebKit function "atob()" and try to save this bytes with following code, I can't open the file.
    this.writeFile = function(outputfile, content, append){
    var file =a ir.File.applicationStorageDirectory.resolvePath(outputfile);
    var stream = newa ir.FileStream();
    if (append) {
    stream.open(filea, ir.FileMode.APPEND);
    }else {
    stream.open(filea, ir.FileMode.WRITE);
    try{//Binärdaten
    stream.writeBytes(content0, , content.length);
    }catch(e){//Textdaten
    stream.writeUTFBytes(content);
    stream.close();
    The same happens when I try to open a file from my HDD and read in the bytes. When I decode it to base64, the string is not equal to the string, which is correct.
    I attached a working Base64 string, which I could convert back to a zip-file via a only encoder.
    So my question is, how can I decode a Base64 string and save the binary data to a file?
    Thank you for your help.

    I rewrote the Base64 decoder/encoder to use it with a ByteArray. Here ist the code:
    var byteArrayToBase64 = function(byteArr){
        var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
         var encOut = "";
        var bits;
        var i = 0;
        while(byteArr.length >= i+3){
            bits = (byteArr[i++] & 0xff) << 16 | (byteArr[i++] & 0xff) << 8 | byteArr[i++] & 0xff;
              encOut += base64s.charAt((bits & 0x00fc0000) >> 18) + base64s.charAt((bits & 0x0003f000) >> 12) + base64s.charAt((bits & 0x00000fc0) >> 6) + base64s.charAt((bits & 0x0000003f));
        if(byteArr.length-i > 0 && byteArr.length-i < 3){
            var dual = Boolean(byteArr.length - i - 1);
            bits = ((byteArr[i++] & 0xff) << 16) | (dual ? (byteArr[i] & 0xff) << 8 : 0);
            encOut += base64s.charAt((bits & 0x00fc0000) >> 18) + base64s.charAt((bits & 0x0003f000) >> 12) + (dual ? base64s.charAt((bits & 0x00000fc0) >> 6) : '=') + '=';
        return encOut;
    var base64ToByteArray = function(encStr){
        var base64s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
         var decOut = new air.ByteArray(); 
        var bits;
        for(var i = 0, j = 0; i<encStr.length; i += 4, j += 3){
            bits = (base64s.indexOf(encStr.charAt(i)) & 0xff) <<18 | (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 | base64s.indexOf(encStr.charAt(i +3)) & 0xff;
            decOut[j+0] = ((bits & 0xff0000) >> 16);
              if(i+4 != encStr.length || encStr.charCodeAt(encStr.length - 2) != 61){
                   decOut[j+1] = ((bits & 0xff00) >> 8);
              if(i+4 != encStr.length || encStr.charCodeAt(encStr.length - 1) != 61){
                   decOut[j+2] = (bits & 0xff);
        return decOut;

  • Streaming of files (doc/pdf/xls)

    hi,
              i try to stream a file like this:
              FileInputStream fileIn = new FileInputStream("d:\\test.doc");
              int length = fileIn.available();
              byte[] b = new byte[length];
              fileIn.read(b, 0, length);
              ServletOutputStream op = response.getOutputStream();
              response.setContentType("application/msword");
              op.write(b, 0, length);
              when I do this in WLS 5.1 SP5 ....MS-Word do open...BUT...
              there are lots of weird characters in the document....!!!
              (the same problem for pdf:s)
              Browser used is IE5.0
              (the code above works fine in another appserver i've tested)
              I'm I missing some HTTP-headers ???
              thanks for any suggestions!
              regards,
              /goran knutas
              

    thanks for your comment,
              but the code-snippet works fine in Orion Webapp server...
              but NOT in WLS 5.1 sp5...that is a bit strange....
              I dont think it has something to do with MS-Word as such...
              though i have noticed that WLS starts every processed page with a lot of
              empty rows..wich is sent to the cliennt...that could be interpreted
              by the Application/Word to be something else...??? or ???
              /goran
              Joe Trung <[email protected]> skrev i
              diskussionsgruppsmeddelandet:[email protected]...
              >
              > Hi Goran,
              >
              > Your codes look great but they won't work due to the internal processing
              of word processors (Adobe or MS winword). The browser depends on
              informations to invoke or to execute the content. Why so complicated? If you
              save a MS doc as a webpage you may see complicated things you couldn't
              imagine. Try the simple way what I did:
              >
              > ejb-2_0-pd2-spec
              >
              > workshop
              >
              > You get on the browser 2 underlined sentences: ejb-2_0-pd2-spec and
              workshop. If you click one of them you get what you expected.
              >
              > Joe
              >
              > "Goran Knutas" <[email protected]> wrote:
              > >hi,
              > >
              > >i try to stream a file like this:
              > >
              > > FileInputStream fileIn = new FileInputStream("d:\\test.doc");
              > > int length = fileIn.available();
              > > byte[] b = new byte[length];
              > > fileIn.read(b, 0, length);
              > > ServletOutputStream op = response.getOutputStream();
              > > response.setContentType("application/msword");
              > > op.write(b, 0, length);
              > >
              > >when I do this in WLS 5.1 SP5 ....MS-Word do open...BUT...
              > >there are lots of weird characters in the document....!!!
              > >(the same problem for pdf:s)
              > >Browser used is IE5.0
              > >
              > >(the code above works fine in another appserver i've tested)
              > >
              > >I'm I missing some HTTP-headers ???
              > >thanks for any suggestions!
              > >
              > >regards,
              > >/goran knutas
              > >
              > >
              >
              

  • Streaming m3u files using iTunes and not QuickTime plug-in

    Hi,
    I am listening to mp3 files using a webserver and streaming m3u files. When I click on the url I get the QuickTime plug-in. I don’t like the QuickTime plug-in very much so I would like to have iTunes starting instead of QuickTime.
    I have chosen to use iTunes for m3u files but it do not work. If I save the m3u file to my disc and double click iTunes is starting as I want but not when clicking on the link in Safari.
    Is there any solution to get iTunes starting when clicking on a link instead of QuickTime plug-in?
    The link looks like this: http://www.samplelink.info/custom.m3u?ltype=SEARCHRESULTS
    Thanks in advance.
    Jarle

    Hi
    I'm generally ignorant in the way of those computer thingies, but seeing as no one else has responded, I'll venture my poorly informed opinion.
    It seems to me that what you're asking for can't be done (as yet). What you would need is an "iTunes plug-in" effectively, which I don't think exists.
    The only way you could set iTunes as the default for playing m3u is to leave the web/browser context (i.e. by downloading the m3u file) and then opening it with iTunes, which you already know how to do.

  • I download, but always saves files of 1KB.  How can I save the whole file.

    I registered the unlock of QT Pro. I try to download, it tries to save audio file as something.mov, but the file is 1KB in size. It actually does not save the whole thing.
    How can save the whole file from a URL?
    Thanks,
    Juan

    The site is probably using pointer movies which may indicate that the movies are streaming and so cannot be saved. I'd suggest checking with site's support staff and ask if the movies are downloadable or are streaming only.

  • Storing streams as files

    Hello.
    I am pretty much a stranger to Adobe FMS, but i hope someone can take the time to answer what i hope is a simple question:
    Is there a way to save FMS streams as files, such as AVI, MPEG or MP4?
    /M@s

    Yes - you can save stream files. You can either save them as FLV (which supports VP6 & Sorenson Video codec, Nellymoser,Speex & mp3 as audio codec) OR F4V/MP4 (H.264,VP6,Sorenson as Video codec & NellyMoser,HE-AAC,AAC as audio codecs). There is one more format called RAW in which you can record your files. But to answer in short yes it does record in MP4 format
    AVI is not supported format

  • I want to save streaming video to watch later

    Hi
    I want to save streaming video to watch later, wma format, whatever
    format is most common on the internet. Quick Time does not
    open automatically when the streaming video starts but Windows Media
    Player opens. What program is low cost that will save the video
    stream that Quick Time Player or Windows Media Player can open?
    thanks in advance
    Mark S

    I want to save streaming video to watch later, wma format, whatever
    format is most common on the internet. Quick Time does not
    open automatically when the streaming video starts but Windows Media
    Player opens. What program is low cost that will save the video
    stream that Quick Time Player or Windows Media Player can open?As I see it, you basically have 3 main options:
    1) Screen Capture -- Any streaming video that can be watched/listened to can be captured. Several applications are available that can do this but I generally prefer SnapzProX. This class of program essentially allows you to "record" the audio and video as it is being played back on your computer. This is normally done using a very simple but very fast codecs which create rather large files on your computer but which can then be transcoded to a more efficient format for playback whenever you wish.
    ADVANTAGES: You end up with a fully self-contained copy of the media which can be locally archived, moved, copied, and is available as long as you keep the copy.
    DISADVANTAGES: This approach can require large amounts of storage space depending on the commpression format used and the number of files stored. Depending on the material involved, this could constitute a copyright violation of media use.
    2) Save As... -- If you have/purchase QT Pro and/or an appropriate third-party QT component (like Flip4Mac in this case), you open open/play the streaming file in the QT Pro Player and save a copy of the movie that contains a resource pointer to the online streaming server. For all intents, you have a "copy" of the file stored on your computer that can, within certain limits, be played back whenever you wish.
    ADVANTAGES: Since the saved movies are very small, you can save a large number of them on your computer. Since they open and play just like standalone movies, they are very easy to use and share. Since control of the content remains with the orginator and access (public or limited) remains as intended by the originator, you would not be violating copyrights here.
    DISADVANTAGES: Material may be changed, removed, or unavailable for one reason or another at any given time. Playback requires connection to the Internet.
    3) Bookmark/URL List -- As a last resort, you can always bookmark or copy the relavent streaming server URL to a "hyperlink" list and open the media manually whenever you wish/are able to do so.
    ADVANTAGES: Nothing to buy.
    DISADVANTAGES: Requires extra effort on your part, still won't open in the QT Player, and still remains subject to the online vagaries mentioned above.

  • How do I save an install file for Photoshop CS6

    I need to get an install file for Photoshop CS6 (not CR) that I can use on a Windows PC that, due to security reasons, does
    not have access to the internet.  In the past I have been able to save the install file for Photoshop and/or Lightroom on my internet connected PC and then move it to the the target PC on a thumb drive or CD.  But now with the CC and the new "Adobe Installer" I can't seem to see how to capture the install file. 
    Please let me know how to do this.
    dan

    Refer to this:
    Direct Download Links for Adobe Software
    Mylenium

  • How can i stop an error message that comes up when i am using word? the error message is "word is unable to save the Autorecover file in the location specified. Make sure that you have specified a valid location for Autoreover files in Preferences,-

    how can i stop an error message that comes up when i am using word? the error message is "word is unable to save the Autorecover file in the location specified. Make sure that you have specified a valid location for Autoreover files in Preferences,…"

    It sounds like if you open Preferences in Word there will be a place where you can specify where to store autorecover files. Right now it sounds like it's pointing to somewhere that doesn't exist.

  • HT201361 Is it possible to save the screenshot files to a different folder than desktop. How can I change the folder?

    Is it possible to save the screenshot files to a different folder than desktop (that is the default). How can I change the destination folder? Thank you, Sal

    To change the screenshot capture location to a new place on your Mac, first think of a location that would serve you properly. We like to place ours in a "Screenshot" folder located inside of the User's "Pictures" folder. To change the location to this new location, open the Terminal and enter the following command:
    defaults write com.apple.screencapture location /Users/[u]/Pictures/Screenshots/
    Replace "[u]" with the name of the user on your system. Once you have entered this command, let's restart the screen capture utility by restarting the SystemUIServer by entering the following command:
    killall SystemUIServer
    You can optionally log out and back in instead of entering this second command, thus restarting the SystemUIServer. Once restarted, all screen captures taken from here on out will end up in your /Pictures/Screenshots/ folder in the User's home folder on your Mac.

  • Cancel cannot save to the file because it is in use

    Hi guys,
    From a couple of days ago i cannot export ANY pdf file in InDesign withouth the "cannot save to the file because it is in use by one or more background tasks". It seems there is a "temporary files" are saving. So the trick is to delete the file from the Finder and save the PDF again. It is annoying that i cannot replace the pdf directly with the same name.
    Can i override this situation?
    Any help or ideas?
    Thanks

    Thanks for the fast reply
    Actually i learn before from a forum that could be an issue so i take care so the file is not marked. Nevertheless it keeps telling me the file is in use. What could it be?
    Cheers

Maybe you are looking for

  • Windows 7 64-bit drivers for HP ScanJet 6200c

    Hello HP, Will you be releasing 64-bit drivers for the ScanJet 6200c?  Regards, Dean.

  • PDF prints a thumbnail and backwards

    I recently upgraded a user to Acrobat Reader 9 and since then, when he tries to print a paper copy of PDF's to his post script printer, they come out as inverted and the size of a thumbnail picture.   Even if he sets the printer to the proper paper s

  • How to extract the excel file using web dynapro

    Hi Expert,    I want to know how to generate an excel file to extract the internal  data. Please give me your help.   Thanks in advance.

  • Updating Microsoft office 2004

    I'm trying to download updates for Microsoft office 2004. The automatic updater runs into the same problem. When it gets to the microsoft site and tries to download the update I need I get an error message saying it couldn't find the server. I've got

  • PDF to iBooks Author Learning's

    Hi All, Here is a blogspot review on PDF to iBooks Development; it has list of leaning out come - which will help many of you looking to develop iBA from BOOK PDF using iBooks Auhtor. http://ibooksauthortech.blogspot.in/2012/10/pdf-to-ibooks-author-l