Streams question / file mapping question

1. I read that I have to close all streams I use. But, on the other hand, in the topic on layering streams (in the same books or tutorials) I see such piece of code:
DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream("file.txt")));It's obviuos that I can explicitly close only the dis stream object. What obout the rest created along the way?
2. I have this code snippet:
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class Main {
    public static void main(String[] args) {
        try {
            FileChannel channel = new FileInputStream("c:\file.txt").getChannel();
            long size = channel.size();
            ByteBuffer buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, size);
            for (long i = 0; i < size; ++i) {
                buf.putChar('a');
        } catch (IOException exc) {
}When the program terminates, the file is not updated. Why is that?
I am using Win XP.
Thanks!

2. Ok, it generated an exception becouse the path was wrong (forgot about double backslach). Here is the code:
package Main;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
public class Main {
    public static void main(String[] args) {
        try {
            FileChannel channel = new FileInputStream("c:\\file.txt").getChannel();
            long size = channel.size();
            ByteBuffer buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, size);
            for (long i = 0; i < size; ++i) {
                buf.putChar('a');
        } catch (IOException exc) {
            System.out.println("Fuck it, an exception!");
            exc.printStackTrace();
}Now it generates a NonWritableChannelException at line:
ByteBuffer buf = channel.map(FileChannel.MapMode.READ_WRITE, 0, size);I just don't get whats wrong with the code.

Similar Messages

  • Photo stream questions, sharing, etc.

    Shared photo stream questions
    Camera Roll (CR), Photo Stream (PS)
    If I create a shared PS and share it with a friend, is this temporary like the main PS (most recent 1000 images)?
    For example, if I put one photo in a shared PS and then take 1000 new photos (but I don't add it to the shared PS), presumably it will disappear from my main PS, but will the original photo disappear from the shared PS, too?
    I noticed that each month I have a new monthly event titled, for example, "August photo stream", etc. Are these temporary, too? If I take 1000 photos in September, will the August PS event start to lose images, or will this only occur in the main PS section?
    Apple's web site says "iCloud stores new photos for 30 days, so you have plenty of time to connect your iOS device to Wi-Fi and make sure you always have your most recent shots handy." What does this mean? If I take a photo on iPhone it's permanently in CR (until I sync with iTunes on OS X and then iPhoto offers to remove them from CR), but they're also in PS, which is temporary, right? If so, as long as CR is permanent, how big an issue is the 30 day rule?
    Here's where I'm (further) confused...
    On iPad, my PS section (the tab on bottom) only has 30, relatively recent photos. Each photo was taken with iPhone.
    However, on iPhone, my PS section has 547 images. Some of these were taken as screen shots from iPad (even though they're not on iPad's PS??) Some of the images were "Save As... "  image files from OS X, some were photos imported to desktop iPhoto from a camera. Many of the images were taken years ago. On desktop iPhoto, I have over 3000 images, but the images on iPhone's PS do not appear to be the most recent 1000 images imported to iPhoto.
    So why did iPad's screen shots disappear from iPads PS yet appear on iPhone's PS?
    Why aren't the two iOS device's PS sections the same?
    Is this confusing to everyone, or am I just dense?
    Thanks!

    You are most likely using the same apple id under settings>iCloud. If you just want to stop the photo sharing you can open settings>iCloud and turn off photostream. If you want to keep using photostream and still not share you need to set up an alternate apple id to use under settings>icloud

  • Streaming Question

    I have an Adobe Premiere project, I need to convert to an swf that can be streamed from a web server. The file is 51 minutes long which to me seems way to big to stream the entire file form one swf without issues.
    I'm not too familiar with streaming and file sizes but the basics tell me that I need to find a way to have the downloaded content, stream enough so there is no pauses but I need to have the quality decent.
    So if the entire file is a 500mb .swf @ 640 x 480  will I have problems streaming this from a server?
    any help?
    rd

    you can calculate each user's download rate (using, for example, some preloader code) and then downloading the amount of your swf that would be needed to ensure smooth play (assuming the download rate is consistant).  start play when that amount is downloaded.

  • How to stream local files (music, etc) to tv over home network

    how do I set up Win7 to enable network tv to stream local files from computer?
    This question was solved.
    View Solution.

    Hi,
    You need hardware (equipment) for this work first. What do you have now ? Please check the following articles:
       http://www.popularmechanics.com/technology/how-to/​tips/how-to-stream-media-from-laptop-to-tv-8347637
       http://www.easyfreehdtv.com/streaming-to-tv
    Have funs and good luck.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • 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

  • Streaming .FLV files from Media Server 4.5 using PHDS

    I would like to stream .FLV files from adobe media server 4.5.
    Requirements state that the files should be considered secret, so I decided that PHDS sounds like the
    right thing.
    I was able to stream an .FLV by placing it in the webroot/vod folder using an url like http://myserver/vod/test.flv
    However the developer manual states that a way to enable PHDS at the server level is to uncomment the two lines like this.
    <IfModule jithttp_module>
    <Location /hds-vod>
        HttpStreamingJITPEnabled true
        HttpStreamingContentPath "../webroot/vod"
        JitFmsDirPath ".."
        Options -Indexes FollowSymLinks
    # Uncomment the following directives to enable encryption
    # for this location.
       EncryptionScope server
       ProtectionScheme phds
    </Location>
    </IfModule>
    However I am not able to stream my FLV using url like http://myserver/hds-vod/test.flv
    Question : Am I supposed to use the hds-vod in the URL or is /vod doing the same ?
                      Is the approach correct, or should the files go into an applications\myapplication\media folder ?
                      I will need some server side actionscript to validate access to the stream, is that possible without a dedicated application ?

    Hi,
    When you use the vod location directive you're basically using Progressive download so your URL is as : http://myserver/vod/test.flv
    However, when you use the location directive hds-vod, it is HTTP Streaming, where the fragments are created on the fly. For this your URL needs to be as : http://myserver/hds-vod/test.f4v.f4m
    Please note .flv files are not supported for HTTP streaming (via hds-vod location directive). You cannot use PHDS with .flv files.
    Thanks,
    Apurva

  • File mapping in R/3

    Hey guys,
    is there a mapping module in R/3 like on PI Enterprise Service Builder? I mean, i want to know whether it is possible to use a standard tool from SAP to do a file mapping to a ABAP structure? E.g. a get a XML file via PI (i know, i could do the mapping in PI) which is routed to R/3. Now i want to do my mapping in R/3. Is there a tool in R/3? I could build such a tool but i want to know, does SAP deliver such a tool for R/3? Is it possible to use the module of PI for mapping in R/3?
    thx for your answers,
          W.

    You do not need another mapping in SAP once the mapping is done in PI. PI will map from external format to SAP IDOC format (either in IDOC flat file based or IDOC XML format). After you drop this mapped file which is in IDOC format (flat file/XML) into the application server (configured in the receiving systems) and trigger the startrfc.exe, SAP would take care of the rest (provided all inbound setting are setup).
    Now if you want a custom ABAP structure, you'll have to mimic the standard FM's. If you have a predefined structure, then create an custom IDOC and a custom FM to process it. Set it up just like the standards and then do the same process - map into the custom format from PI and then trigger the RFC, this would trigger the process code and invoke your custom FM to process this custom IDOC/structure.

  • How can i stream some files via my macbook pro

    how can i stream some files via my macbook pro and my WD TV LIVE

    Which email client are you using & which version?   Your emails are not appearing in the email trashcan? 

  • "Could not open a file mapping" and crashes.

    Hello. I've just downloaded ReaderX from Adobe website. Rebooted. Now when I try to start Reader, the message box with title "Adobe Reader:AcroRd32.exe - Application Error", and the message box contents are "Could not open a file mapping". Reader window does not even show. When I click OK, the program terminates.
    What can I do to fix this error?
    I have a Windows 7 x64 installed.
    Update: Uninstalled, rebooted once again, reinstalled reader, now all works. Thread can be closed.
    Update2: After a hour of successful usage, I closed the Reader and then tried to open it again. Same problem with "Could not open a file mapping". Any suggestions?

    Repair via ARP is go to Add Remove Programs and select Adobe Reader, You will find two options highlighted one is repair and other is remove.
    From there you can Click on repair and click on next. It will repair your Reader install if there is some file missing.
    What are the other applications you have installed on your PC?

  • Unable to stream SMIL files unless the html page, swf file and the smil ffile are on the FMS server.

    When I place the .swf, smil and http files on the FMS server the SMIL stream test sample works fine
    But When I move the files to my web server I get Connection error.
    This is the same issue discussed in http://forums.adobe.com/thread/554107
    I added a ‘base’ variable but it did not work for me.
    The SMIL file has the correct path to the sample files and FMS server
         <meta base="rtmp://200.200.200.23/vod/" />
    I am able to stream files from my html file on my webserver not the FMS server by pointing to the FMS server at rtmp://200.200.200.23/vod/mp4:sample1_1500kbps.f4v
    Is this a domain security setting? If so, where do I change it?
    If not How do I get FMS to stream SMIL files without installing a webserver with FMS?
    Thanks,

    Hi,
    I think there is bug with that videoPlayer.swf which is used by index.html of webroot folder of FMS to play media files, its not able to parse smil file correctly. I used some other player and used the smil file and kept it on http server other than fms server so it was able to dynamically stream videos. So I would suggest you to create your own player which uses smil file. You can take help from the below link to create player:
    http://www.adobe.com/devnet/flashmediaserver/articles/dynstream_advanced_pt1_05.html
    Regards,
    Amit

  • 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
              > >
              > >
              >
              

  • How to insert a streaming audio file/link into a basic HTML page?

    I am a novice webmaster managing the website for our arts organization.  I am trying to build a simple table on a page of our site that will have about 30 streaming MP3 audio clips for our members to review.  I'm using Amazon CloudFront and Amazon S3 to host and stream these files (using an embedded JW Player?).  Can someone explain to me how to insert these media files into my Dreamweaver page in the most simple way? 
    Up until now, I've been just inserting downloadable MP3 files as quicktime plugins (also hosted at Amazon S3) but with 30 files that gets pretty cumbersome because they all begin to progressive download at the same time. 
    Thank you.

    I simply want a basic playlist for  MP3 files.  What is the type of playlist I want in that case? 
    XML would work.
    http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/5768/how- to-embed-jw-player-with-an-xml-mp3-playlist
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • Flat file mapping problem.

    Hi,
    I've just created a file mapping, and i'm trying to split a flat file field into 3 subfields for a xml record, but i have the following message:
    Before the process run, i've tested the message mapping and the interface mapping, and the log result said that the mapping has been successfully ended, so, Have you ever seen this problem before?
    I appreciate your help, thanks.
    Marzolla.

    Hi Jorge,
              Check your XML input. Try to put the same xml instance in the message mapping transformation and test it out.
    Regards,
    Dhana

  • File to file mapping without xml

    Hello,
    is there a possible way to use a PI7.1 file to file mapping (one static-positioned field must be mapped) without storing the file in xml format ?
    We are having a flatfile and have to send this flatfile through our jms receiver adapter(as flatfile structure) but there is one important field which has to be mapped/changed(static value for all files).
    Our SAP Applikation (File sender) would avoid to change this during or after creating the flatfiles in the R/3 System.
    Thanks,
    Gordon

    Hi Gordon,
    >- Do you have an example for that abap mapping ?
    DATA g_str TYPE string.
      CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
        EXPORTING
          im_xstring  = source
          im_encoding = 'UTF-8'
        IMPORTING
          ex_string   = g_str.
      REPLACE 'ABC' WITH 'XYZ' INTO g_str.
      CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'
        EXPORTING
          im_string   = g_str
          im_encoding = 'UTF-8'
        IMPORTING
          ex_xstring  = result.
    >I think i have to use some entry parameters for my interface right ?
    ?? no..
    >- Is it possible to use that within the integrated configuration ?
    ??  yes..
    Regards,
    Udo

  • File Mapping from Servlet to client

    Hi,
    I want help in Servlets....
    My problem is, i am having one servlet and one client(Html) and one imageFile. My servlet knows the filePath, now it has to process the filePath so that the imageFile is displayed in Html. Now, the issue is in servlet is there any other procedure other than streaming the file in to ServletoutputStream??? I know that the following code solves my problem,
    File f = new File("F:\\Images\\2\\3\\2004\\12282004\\08\\1.jpg");
    byte[] imageData = new byte[(int) f.length()];
    FileInputStream fis = new FileInputStream(f);
    fis.read(imageData);
    response.setContentType("image/jpeg");
    ServletOutputStream out = response.getOutputStream();
    out.write(imageData);
    But what I want to know is, instead of Streaming the file into byteArray and set into ServletOutputStream, is there any other alternative???
    Thanks in advance
    Regards,
    Rama Sarma Vemuri L S K
    Mobile: +91-9885584568

    Hi,
    If we stream and send, it ll be taking much time in case of bigger images. So, I am trying like this. What I do os, in my Img tag, i ll call servlet which fetches me the URL of image and I ll the display the same. This is what I want to achieve. Can you help me out???

  • File Mapping Issues

    Hi all,
    I am desperately seeking some insight regarding the OSX file mapping state.
    Just recently in August, my near-8 year old G3 Wallstreet running OS 8.1 pooped-out, so I ended up buying a 1.5ghz 12" PowerBook running 10.4.0. Lovely hardware. Mmmmm.
    During the first month or so, I ran into several unfamiliar issues (as I currently need to run 'Classic' as well) that I was able to work out on my own and since have learned a lot about this new OS to eventually move as many apps as I can to OSX.
    But I keep getting sidelined every now and then with this d@mn file mapping thing re: .EPS files.
    The problem arises when I have Adobe Illustrator EPS files and Photoshop EPS files on the same hard drive. With extensions necessary (due to cross platform exchanges required in my biz) confusion arises. I assign a Photoshop eps file it's application, then when I go to do the same with the Illustrator eps, it defaults to Photoshop -- and I can't change it for the likes of me. I use OnyX to 'Reset the Application Links' and start over -- usually in a different sequence. Sometimes that has worked. Not always. It appears no one thought of this when developing OS X, short of the pithy "Internet" control panel in OS 9 that proclaims that OSX takes it's cue from entries here. (Really?) At first I thought it was because I am using a mixture of 'Classic' apps and native ones. I find out from my peers this happens with them too. In OS 7/8/9 this was NEVER EVER EVER an issue. As a working professional, who bills by the hour, OS X is making my life twice as difficult now. Every time I have to deal with this I lose 2-3 hours of billable time trying to troubleshoot this 'oversight'. This has happened 4 or 5 times now since I bought this PowerBook in August '05. I hate to say it, but even WinXP Pro is more forgiving in this area -- (and only in this area)
    Does anyone out there know of a sure-fire Pref Panel, or anything like that, where you can go in and assign File Type, Creator and Extensions -- and it actually works -- rock solid? I've tried the DefaultApp pane to no avail, and everything else wants me to drag-n-drop folders to re-assign. Other tools I use for various things are: OnyX, Drive Genius, MainMenu and File Adopter.(For the record, I am aware of the Cmd-i > Choose > 'Always open with' > Select application routine -- somethings it works great with, others not)
    It's a pain not knowing what TYPE of EPS was just sent to me. Vector or Bitmap. When it comes from the PC world, who knows. I used to be able to tell in OS 8.1.
    Regardless, I'd like to stop tearing my hair out and just get back to work on this lovely little piece of hardware.
    Thanx in advance!
    12 G4 PowerBook/1.5 & PB 3400c/200   Mac OS X (10.4.2)  

    I suspect the confusion is due to the things that are sent to you from Windows machines. OSX can assign things with the same extension to different applications, provided the resource fork is there and shows the creator of the file. Thus, I have a pair of .eps files created on Macs, one is an Illustrator file and sports the Illustrator icon and is set to open by default in Illustrator. The other is a Photoshop eps file, has a custom Photoshop icon, and the defaut to open it is Photoshop. All well and good. But if there is no resource fork then that too is a "type" and the Mac will open it with whatever default application you assign to files that have an extension of eps and no creator code. This will be the case for files received from a Windows machine. Unfortunately in this case the "type" of eps and no creator code includes two possible applications and you can only pick one or the other as the default. Without the creator code there is no way for the Mac to tell which way to go. There may be in the future, since the actual creator may be included in the metadata, which may also be a part of Windows Adobe files (I don't have any to test so I don't know), and in the future this may be readable by the system. That's a lot of "maybes" and doesn't help right now.
    If those who send you files tell you whether they used Illustrator or Photoshop, I believe you can batch assign a creator code using SuperGetInfo from BareBones.
    Francine
    Schwieder

Maybe you are looking for

  • Problem with PDF output quality

    We recently upgraded to CS4 Suite Design premium and i am having problems getting illustrator to print high quality output.  I have a file created in illustrator which contains 300dpi tiff images created in photoshop (CMYK colorspace in both photosho

  • Linking to new page from BLOB image in report

    Hi Guys, I have added an image to my report using the number/Date format field IMAGE:CITIES:CTY_PHOTO:CTY_NR::::::inline:Download. This works great! :) I know want the user to click on the image and go to the next page, setting the city code that was

  • Material document cannot be processed in MBST trasanction

    Hi, We want to cancel a Material Document Number 4906026157/2010, but system is giving an error message: Material document cannot be processed Message no. M7130 Scenerio: - User rejected the material by 122 mvmt. for rework on this material, after th

  • OWB ERROR:  created with second class object failure

    I'm getting this error when I import a table into the repository. any ideas? created with second class object failure

  • How to autostart weblogic server in windows

    Hello, Can somebody one the setting change/or modification in any of the scripts we need to do for autostart of weblogic server if it crashes due to some reason. Thanks in advance Ram