Reading a fle format thats part ascii and part binary

Hey
I'm trying to write a importer for the PLY filke format. That file format starts of with a header in ascii and then continues with either the data in ascii or in binary. When the data is in ascii I have no problem reading the file but when the data is in binary I'm noth quite sure how I should do it. Right now I do something like this:
BufferedInputStream stream = new BufferedInputStream(new FileInputStream(file)); // I first create this
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));  // then this is for reader ascii
DataInputStream dataInputStream = new DataInputStream(stream); // And this is for reading binaryThen I read the ascii header with the BuffereReader and then wheter I turns out that the data is in ascii I countine reading with the reader, otherwise I start reading with the DataInputStream. But the data from the DataInputStream is not the same as I get from the BufferedReader. I try it on these files that are in diffrent endians and either ascii ot binary
http://www.cs.ucl.ac.uk/staff/Joao.Oliveira/ply.html in the Nbunny.zip.
Anyone that can help me with this? Or know about a PLY file reader in java already?
Discordia
Message was edited by:
Discordia

DataInputStream is NOT the right class to use for general binary input. It is used only for the specific purpose of reading Java primitives. The input obviously needs to be in the right format for that to work, i.e. it needs to be written using a DataOutputStream.
I would read everything using an InputStream, not a reader. Store the bytes of the header until you reach the end of the header (not sure how to determine that since I don't know the fileformat). Then convert those bytes into a String using the proper charset ("US-ASCII" in this case, if by "ascii" you really mean ASCII).
Then just continue reading the binary data.

Similar Messages

  • Option to read fixed-length format, EXCEL or ASCII TAB delimited

    Hi Experts,
                      I have a requirement for giving an option to read fixed-length format, EXCEL or ASCII TAB delimited in the selection screen.Kindly help me how can i read the fixed length format?
    Thanks,
    Ankita

    As far as I could have understood your problem
    You have to read the file with
    Open dataset  'file path+name'  FOR INPUT in text mode encoding default.
    and move its contents to string type variable
    Transfer to 'file path+name' to v_string.
    Now as per your requirements you need to use Offsets to transfer the data into a work area.
    For example
    wa_task-year=  v_string(4).
    wa_task-month=  v_string+4(2).
    Please confirm if this is your requirement.

  • Text format ITF RTF ASCII and RAW

    I want the detail information about these text format ....
    I mean...
    How the data is actually stored???
    What about the length of the data???
    when to convert which data into which form???
    and what are different converting function modules??
    also more about RAW format??
    how to convert RAW data into other format??
    Thanks in advance.
    Regards,
    Jayavant
    Edited by: jayavant deshpande on Dec 18, 2007 7:04 AM

    >
    14.4.1 Importing the Subtemplate
    Enter the import command anywhere in the main template prior to the call template command as follows:
    <?import:xdoxsl:///{path to subtemplate.xsb}?>
    where
    path to subtemplate.xsb is the path to the subtemplate .xsb object in the catalog.
    For example:
    <?import:xdoxsl:///Executive/Financial Reports/mySubtemplate.xsb?>
    >
    from http://docs.oracle.com/cd/E23943_01/bi.1111/e22254/design_xsl_sub.htm#abt_xsl
    >
    Using http protocol:
    <?import:http://www.server.com/common/subTemplate.xsl?>
    Using file protocol:
    <?import:file:///C:/Files/common/subTemplate.xsl?>
    >
    for ebs as example
    <?import:xdo://OKC.OKCTCINC.en.00/?>

  • Video formats that iTunes/iPods will read?

    Trying to figure out all the formats that both iTunes and iPods will read when used with Podcasting that involves video. I've tried .m4bm, which doesn't work when clicking on the small screen to get a bigger view. All I get is a single frame. I've also tried converting to .mov and that doesn't work on the iPod. Thanks in advance.

    iTunes and iPod (Video) will read:
    .mov
    .mp4
    .m4v
    Just to clarify, videos with an .mp4 or .m4v suffix are the same - both can be opened by QuickTime Player and iTunes. The only difference is that double-clicking a .mp4 will (by default) open it in QuickTime Player while double-clicking a .m4v will open in iTunes.
    It's not possible to make assumptions about a .mov file and it isn't really a "video format". Think of it as an envelope that can contain many different types of media formats. For example a Windows Media Video track in a .mov container can be played by QuickTime Player (using a free plug-in) but this won't work on the iPod. If the .mov uses a component that's part of the standard QuickTime install then it should play on the iPod. But because of QuickTime's plug-in components it's not possible to assume that a .mov file that plays in QuickTime Player will play on an iPod.
    Hope this helps
    PowerBook   Mac OS X (10.4.7)  

  • Reading Camera Raw Format

    I'm a user of Lightroom 5 and Photoshop CS6 runiing the current version of each.  I signed up for Creative Cloud and have downloaded and installed Photoshop CC.  I have not downloaded and installed Lightroom from CC as I understand it is the exact same product as the standalone version.
    My question is - everytime I take a photo (DNG) from Lightroom and click to edit it in Photoshop CC - Photoshop CC opens a dialog box that says 'Reading Camera Raw Format'  That didn't happen when I opened images in CS6.  What causes this and how do I fix it?
    I have checked with a friend who also converted to Photoshop CC and he does not get that dialog (he is running Windows and I'm on a Mac)?

    Since you say you are up-to-date with LR an PS, this suggests you are using LR 5.2 and PS-CC/ACR 8.2.
    Whenever the versions of LR and ACR are compatible, then LR tells PS to open the raw file using LR’s settings, and PS uses the ACR plug-in to open the raw file with those settings.
    The message occurs when the time it takes to render the raw file on the way into PS longer than a certain amount of time. 
    If your LR and CS6-ACR were up-to-date and you weren’t seeing the message, then perhaps something was slightly faster with those two products, and the message wasn’t displayed, or perhaps PS-CC’s time-limit for showing that message was made a shorter amount of time.
    If your LR and CS6-ACR weren’t synchronized in their versions (e.g. LR 5.2 and CS6-ACF 7.1) then LR could have been rendering the file as a TIF or PSD so PS isn’t using ACR to render the file.
    As far as LR-non-CC and LR-CC being the same.  They operate on images files the same, the real difference will occur with LR 6, which you won’t have to pay extra for if you’re using the CC version. 
    There isn’t any reason to download and install LR-CC 5.2 when you already have the regular LR 5.2, but once LR 5.3 comes out, you might as well let CC download and install it, so you won’t have to worry about it, later.  It may be that you’ll have to uninstall LR non-CC 5.2, but perhaps that has been changed in recent updates of the CC Manager app or will be when LR 5.3 is release in the next few weeks.

  • Incrementing Ascii and integer loop

    Hi there,
    Just wondering if anybody can help me with this little problem that I have... I'm trying to write a loop that increments ascii and integers. It should look something like this:
    0 1 2 3 4 5 6 7 8 9 A B C D ..... X Y Z 00 01 02..... 0A 0B 0C .... 0Z 10 11 .... ABCD1 and so on...
    I got the loop bits but I don't know what I can do to combine the 2...
             for (char x= 'A'; x <= 'Z'; x++)
                   System.out.println("Count is:" + x);
             for(int i=1; i<11; i++){
                   System.out.println("Count is: " + i);Can anybody give me some tips please? Thanks in advance!

    you can do this you know
    for(int i=0,char a='a';i<11,a<='z';i++,z++)and then print whatever you want to

  • "It is formatted incorrectly, or is not a format that iBooks can open". Can anyone help me with this message of a book that I purchased on iBooks, read, highlighted in the book and now I can't open it anymore. Please help!!!

    "It is formatted incorrectly, or is not a format that iBooks can open". Can anyone help me with this message of a book that I purchased on iBooks, read, highlighted in the book and now I can't open it anymore. Please help!!!

    Mine does the same thing occasionally, is your phone jailbroken? Sometimes it will work if you delete the book and reinstall it or put your phone into airplane mode then turn it back off.

  • HT2963 I have a 1 TG external drive that is formatted to Windows NTFS and is read only, how do i get it to read and write on my Mac OS X 10.6.3?

    I I have a 1 TG external drive that is formatted to Windows NTFS and is read only, how do i get it to read and write on my Mac OS X 10.6.3?

    Install software such as Paragon NTFS, or reformat it as Mac OS Extended (Journaled) or FAT32. Mac OS X 10.6.5 and newer can also read and write exFAT partitions.
    (97498)

  • HT3775 Hey I have a movie that plays on AVI format but my laptop is not reading it. it says that is missing a codec and cannot be read. can somebody help me please

    Hey I have a movie that plays on AVI format but my laptop is not reading it. it says that is missing a codec and cannot be read. can somebody help me please

    Luigi1990 wrote:
    Hey I have a movie that plays on AVI format but my laptop is not reading it. it says that is missing a codec and cannot be read. can somebody help me please
    Try installing VLC Player for Mac
    http://www.videolan.org/vlc/download-macosx.html
    Cheers
    Pete

  • I've read that Promise Pegasus2 series does not sell replacement parts. I'm buying the new MacPro but am concerned about spending $2K for storage that may break and cannot be fixed. What are others buying for storage for the new MacPro?

    I've read that Promise Pegasus2 R6 thunderbolt 2 series does not sell replacement parts (no replacement parts for any of the Pegasus line). I'm buying the new MacPro but am concerned about spending $2K for storage (12tb version) that may break and cannot be fixed (am told that one must purchase a new unit if a part breaks). What are others buying for storage for the new MacPro? Thanks so much for your help.
    Discussion about this issue at MacWorld.com:  http://www.macworld.com/article/2082783/first-look-promises-pegasus2-r6-thunderb olt-2-raid-array.html

    I've used the original Pegasus R6 units for a couple of years now and have been very pleased with them.  On the two occasions I've had to call on their technical sujpport, I've found them readily available, knowledgeable, and very helpful.  In one case it involved the reset of a unit after a power failure at an inopportune time; in the other case it was a question about upgrading disk drives to higher capacities (1 Gb gto 4 Gb).  I was pleased to learn that their tech support people were in California and as good if not better than upper-tier AppleCare reps. The hardware itself has functioned flawlessly so far.

  • I have edited photos in i-photo and would like to have them printed.  How do i burn them to disc in a format that a windows PC system can read.  I am in India and this is definitely "microsoft" country!  thanks for taking the time to guide me.

    I have edited photos in i-photo and would like to have them printed at any photo development lab.  I am in India and this is definitely "microsoft" country !
    Please advise me how to burn these edited photos to a disc to take to the nearest printing store in a format that "windows" system can understand.
    Thanks in advance.  I look forward to learning about this. 

    Select the pics in the viPhoto Window and go File -> Export and export them to a folder on the desktop. Burn that to disk with the Finder's burn command. Result. A disk with a folder of images that any machine can understand.
    Regards
    TD

  • I am using Adobe XI Pro and in various parts of the document there is brown / biege lettering when on the document it shows as black.  My printer guy has been in and checked it out top to bottom and that part is fine.  I have tried to print the same docum

    I am using Adobe XI Pro and in various parts of the document there is brown / biege lettering when on the document it shows as black.  My printer guy has been in and checked it out top to bottom and that part is fine.  I have tried to print the same document and it comes out fine.  Any ideas ?   Using Windows 7 Service Pack 1

    Sorry my bad.  I have tried to print the same document on another printer and all the formatting is fine. 

  • I'm running snow leopard. The try to open any .mov file in Quicktime, and I get an error message that says, "The document xyz.mov could not be opened. The movie is not in a format that Quicktime player understands. I'm a recent upgrade to Snow Leopard.

    I'm running snow leopard. The try to open any .mov file in Quicktime, and I get an error message that says, "The document xyz.mov could not be opened. The movie is not in a format that Quicktime player understands. I'm a recent upgrade to Snow Leopard.
    Help!
    Thanks, Mark

    Unfortunately, the error message gives no details about what codec might be missing or what it needs.
    If the file can't be opened in QT, it only means you cannot use the QT "Inspector" window to check what compression formats were used to create the file. It does not mean you can't use the Finder "Information" window to check on the compression formats or use a third party media information window (e.g., like VLC which will open many compression formats not supported natively by QT) to determine what kind of data is included in the MOV wrapper. If the file cannot be opened in any app, it is usually a good sign that the file itself is corrupted.
    It's a stupid error message. Apple should do better than that.
    Error trapping is quite extensive but there are still many areas which require human oversight. The message is telling you that either the container has a problem (e.g., not properly terminated, non-standard, or corrupted) or that one or more of the compression formats used is not supported by your current codec component configuration or that the data was encoded using non-standard settings or preferences not supported by QT or that the fourCC code does not match the data contained in the file or that there are timecode inconsistencies, etc., etc., etc. In short there are a near infinite number of possible problems for which it would be very difficult/nearly impossible to program error trapping depending on your sourcing of content and how you process it before it reaches the player app. Think of it like trying to play a BD disc in an DVD player.
    I'll call Apple support when I get a chance.
    Chances are good that they will end up sending you back here. In any case, it is often a good idea to post a sample file for examination by other QT users. At the very least, they should be able to tell you if the sample file will play on other systems which would indicate whether or not the file itself is bad and under the best of circumstances whould allow them to examing the file in detail for various common problems.

  • I have an external hard drive that was formatted by a PC and has files and directories etc. I want to format it and use it on my IMAC for backup but I can't seem to write to it nor can I delete current content. How do I initialize it for use with the MAC?

    I have an external hard drive that was formatted by a PC and has files and directories copied to it etc. I want to use it on my IMAC for backup. I see it on my my IMAC . I can open files etc.  But I can't seem to write to it nor can I delete current content. I don't care if I lose current content. How do I initialize it for use with the MAC?

    You can't write to it because it's formatted as NTFS which OS X will read but not write to. If you want to continue using the drive with both a PC and OS X you will need to download and install NTFS-3G so you can then write to it from your Mac. You can get NTFS-3G at:
    http://www.macupdate.com/app/mac/24481/ntfs-3g
    If you want to use the drive exclusively with your Mac then move the data off it and reformat it in Disk Utility (Applications - Utilities - Disk Utilities) as Mac OS Extended (Journaled.)

  • How can I use an external player for MP3 and MP4 fomats without disabling native HTML5 playback support for mpeg formats that are embedded in webpages?

    The Application options were poorly implemented, resulting in multiple instances of handlers for some formats in a long and confusing list. Now Mozilla seems to have solved that problem by preventing users from choosing how various media formats are to be handled -- the cure is worse than the disease! I am getting damned tired of researches into how this or that poor new decision in Firefox's development can be overruled, circumvented, or lived with. How can I choose how an .mp3 file is to be played, and what is going on at Mozilla that I have to ask?

    Right-click the link and choose Save Link As to download the file. Afterwards, click the Downloads button on the navigation toolbar and left-click the downloaded file. This will open it with the associated application.
    * [[Find and manage downloaded files]]
    Setting ''media.windows-media-foundation.play-stand-alone'' to '''false''' in [http://kb.mozillazine.org/About:config about:config] is the only way to prevent files like MP4 and MP3 being played inside the browser when left-clicking the links, until the preferences for handling such files are properly fixed at some point in the future. That will happen whenever a developer finds the time to write a patch.

Maybe you are looking for