Java IO for different file encodings

Hi,
I need a file reading mechanism, wherein i should be able to read files of just about any encoding (eg Shift JIS, EBCDIC, UTF, Unicode, etc).
I could do this using the following code:
               FileInputStream fis = new FileInputStream("D:\\FMSStub\\ZENMES2.txt");
               InputStreamReader isr = new InputStreamReader( fis, "Unicode");
               BufferedReader br = new BufferedReader( isr );
               br.read(c1);
But there is a requirement in our code, to also read some trailers from the file and go back and again read from the middle of the file. Basically a seek kind of functionality.
I have been desperately trying to figure out how i can do seek (which is possible with RandomAccessFile, but RandomAccessFile wont work with all the various encodings...i have tried this) with the above kind of code.
Any information on this would be very useful.
Regards,
Mallika.

Hi,
Thanks for your reply.
But as you say, when i do a new String(byte[], "encoding") my String does not get formed.
The case which i tried was a unicode file.
I read first few bytes and formed a string as follows:
     byte blfilestr[] = new byte[1000];
               ra = new RandomAccessFile("D:\\FMSStub\\ZENMES2.txt","r");               
     ra.seek(0);
     int ilrd = ra.read(blfilestr);
     String gfilestr = new String(blfilestr, "Unicode");
This gave me the String correctly.
But then i did a seek at an intermediate position in the file (but its a locaiton which i confirmed is not in between the 2 bytes of a Unicode char) and it fails to form a string correctly. I need to do this though.
Any ideas ?
Mallika.

Similar Messages

  • Hello, i need a free java editor for rtf file !

    hello, i need a free java editor for rtf file , that its compatible
    with wordpad of windows, i have tried some of it but they are not compatible ,
    example: not mantain the tabs and the formattings of the text.
    Thanks

    hello, i need a free java editor for rtf file , that
    its compatible
    with wordpad of windows, i have tried some of it but
    they are not compatible ,
    example: not mantain the tabs and the formattings of
    the text.
    ThanksWhy are you using rtf files? .java files are plain text with no formatting info.

  • Java Mapping for Flat file

    hello SDNers,
    I am using JAVA mapping for converting FlatFlie IDoc to IDoc and i am using metadata for this.While downloading metadata from SAP system, the first segment in the data record is having level 2.
    1) What is the use of Level in metadata?
    2)  What is the Level for first segment in data record of metadata. Is it Level 1 or Level 2?
    3) I am facing an error while appending the node. Is it because of Level differs?
    Plese help me out and thanks in advance

    Hi,
    >>>I am using JAVA mapping for converting FlatFlie IDoc to IDoc and i am using metadata for thi
    why do you develop is from scratch is the code is already there - just copy and paste...
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/46759682-0401-0010-1791-bd1972bc0b8a
    >>>1) What is the use of Level in metadata?
    this shows how the nested segments in IDOC are to be understood
    >>>3) I am facing an error while appending the node. Is it because of Level differs?
    no, it becase your code is incorrect - the level velidation will be done at the receiver
    Regards,
    Michal Krawczyk

  • Media Player for different file formats

    I wonder if you could help me.
    I run a media website. I allow users to download videos and
    audios.
    90% of my videos are in .WMV and some are in .RM and .AVI
    formats.
    My audios are in .MP3, .RM and .WMA formats.
    Now, I want the users to view and listen to these
    videos/audios before they download them. Can you tell me what I
    need to achieve this?
    I think, I need a media player that I can include in my
    webpages, and provide it the link to each different file on my
    server. Which media player is able to play all of the above
    formats?
    Waiting for the reply.
    Thanks

    AIFF would be uncompressed, so clearly the best quality, but the file sizes would be huge. 80 minuntes = 700MB, so basically a 2GB Nano might be able to hold two albums if stored in AIFF format. So I am thinking, you don't really want that one.
    AAC format is supposed to give better quality for the same bit rate as MP3. In other words a 128kbps second AAC is claimed by Apple to be at least as good as a 160 MP3. So theoretically, your 192kbps MP3s might be the same quality as 160 AAC files, so going to AAC at 160 would give you smaller file sizes without loss of quality.
    However I don't think you would realize that if you converted your MP3 files directly to AAC files. I think it would only truly work if you started with the original CDs again and reimported them to AAC files.
    Me, I just stick with 192 MP3s and am happy. And my files are more universal than AAC files so I can put them on a CD that will play on my Denon stereo CD changer or in my wife's car CD changer or my daughter's old portable CD player, all three of which support MP3 files and none of them support AAC.
    Patrick

  • Same logo printing different colors for different file formats?

    I created a logo for a client who will be using it for some printed materials.  I provided the logo in 3 different file formats: EPS, JPEG and Tiff.
    In INDesign and MS Word, the logo is printing a different color for the EPS vs the Jpeg/Tiff file types.  Is there something I'm missing?
    I've even tried changing the color to something completely different and we are getting the same result.  There is STiLL a considerable difference between the Eps file and the other two files.

    No the logo was created for print and I originally had used a pantone color but converted to CMYK.  The actual value is C69 M7 Y0 K0.  When my client inserts the eps file into her InDesign layout, it prints a bright aqua color and if she uses either the jpeg or tiff, it is a much different blue.  We've tried other colors because I was thinking it might just be the fact that it's a blue color... but the same thing happens to other colors. I am wondering if there is some sort of color management setting that is causing the eps to be different?

  • Script for creating different watermarks for different files

    Is there a way to create a script to place different watermarks on different files all at once?  Please help me out if you can, thanks!

    How do you define the watermarks? Text? Shapes? Images?
    How are the watermarks mapped to the files?

  • Java mapping for Dynamic File name: stuctures?

    Hi,
    Scenario:  Sender AS2 adapter --> PI --> Receiver File (NFS) Adapter. Just a file pass through, no mapping
    Requirement: Want to have the receiver file name as C1.yymmdd.C2 where C1 and C2 are contants and yymmdd is current date.
    I was told in sdn forum that I have to write java mapping and provided the sample code also. However, I am not sure how and where to use that sample code. Could you please help on following questions:
    1) What is the source and target data type structures for mapping?
    2) Where do I develop java mapping? How do I import to PI?
    3) How do I get access to SAP Netweaver Developer Studio? Can I download it to my laptop? or if I dont have access, can I use any other tool to develop? ( NetBeans, Eclipse ??) and how?
    4) what are the files and libraries that we need to import to java mapping? (e.g.,  Import aii_map_api.jar library)
    5) How to generate .jar file?
    If someone has already developed java mapping (.jar file) ready to import into PI, please provide the same.
    Thanks in advance
    - Riya Patil

    Hi Sarvesh,
    Is this UDF work if I dont select ASMP on sender side? (We tested selecting ASMP on both sender & receiver file adapters, it works fine and it works without UDF also).
    In my requirement I have to use sender AS2 adpter, please confirm if I can use this UDF without selecting ASMP on sender side.
    I have done the following tests:
    Test-1) Select ASMP with 'File Name' on both sender and receiver file adapters without any mapping (UDF)
    It works great. No UDF or mapping required. It is just pass through of file having the receiver file name same as in sender channel.
    Test-2) Select ASMP with 'File Name', only on receiver file adapter without any mapping (UDF)
    It is obvious, it doesn't work. I am getting the following error:
    Could not process due to error: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header
    Test-3) Select ASMP with 'File Name', only on receiver file adapter with mapping (using DynamicConfiguratio UDF)
    We are getting the following error message in SXMB_MONI:
    Fatal Error: com.sap.engine.lib.xml.parser.Parser~
    <SAP:Stack>com.sap.aii.utilxi.misc.api.BaseRuntimeException thrown during application mapping com/sap/xi/tf/_MM_Filename_: Fatal Error: com.sap.engine.lib.xml.parser.Parser~</SAP:Stack>
    Here is the code we have in UDF:
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String SourceFileName = "C1." + a + ".C2";
    conf.put(key, SourceFileName);
    return " ";
    So looks like UDF is not working and it is failing in mapping. If I could make it work, I think there is good chance that I can see DynamicConfiguration under SOAP Header, which what required for the error we see in out test-2.
    Can someone please help me to straighten this UDF and make it work.
    Thanks in advance.
    - Riya Patil

  • Java version for class file

    i have some class files, and i need to know what Java compiler used to compiled that class file (only care for the version number...like 1.4.2, 1.5.0, 1.1.0, etc)
    any one know how i can get this info? or any good google keywords?

    thanx, since now i know how the class file bytes are set up..i guess i can get the version number by looking at the hex.
    tedious (but not that tedious)...thought there be a simplier way...oh well..
    thanx again

  • Java API for SCA File reading

    Hi all,
    I would like to read the content of SCA files with a java api.
    Is there a way to do so?
    Thanks
    Thomas

    FYI - got a response from official SUN support that Sun PKCS#11 is the only available JCA provider for SCA-6000 board.

  • CSS problem using different folders for different files

    So I am trying to organize my files into different sections
    so that updating will be easier in the future. However right now,
    when I create a file in a new folder, my drop downs quit working on
    the files inside the folder and some of my css (mainly the css in
    my IE conditional statements). My drop downs do work if I put a
    copy of the css that controls the drop downs into that folder. The
    thing is, if I ever want to update the css, I want to update it in
    only one spot rather than in ever folder that I had to copy it
    into. How do I get my folder files to work from the css files that
    I created inside my local root folder?

    I managed to slove this by creating symbolic link to the new location on filesystem.
    I was hoping there was some more elegant solution for moving backup sets.
    Thanks,
    -- dragisa
    Ok I understood you. You have to restore your backup
    sets in the same location where RMAN backuped them
    because that information is stored in the catalog.
    In fact, if you remove the backup sets from the disk
    , they get "Expired Status" and if you restore them
    to disk the status is going to be "Available". Test
    it!!!
    To carry out this you have to use crosscheck
    command.
    Joel Pérez

  • Need Java api for .class file comparison....

    Hi all,
    In .net one CecilAssemblyAnalyzer api is der it analyze the two version of .net applic in offline mode (pick .exe and .dll files)
    n forms tree structure and den copares both tree n get the changed function..
    i need same type api in Java...
    Thanks in advance..
    Regards,
    Sachith

    <blockquote>quote:<br><hr><i>Originally posted by: <b>sunny_rush</b></i><BR>com_beacon_essbase_jni_EssApiJni.c:15:20: essotl.h: No such file or directory<BR><hr></blockquote><BR><BR>That package does not appear to be from Hyperion but rather from a third party. Based on the name, it may have come from Beacon Analytics which is now part of Answerthink. Did you have consulting from them in the past?<BR><BR>Tim<BR><BR><BR>

  • Java code for Compressing files in UNIX

    Hi ,
    i am trying to compress files in unix but not seeing any change in size of packed file .any code please help.

    Hi ,
    i am trying to compress files in unix but not seeing
    any change in size of packed file .any code please
    help.Does this question have anything to with Java whatsoever? If so how? And what types of files are you attempting to compress? If you are trying to compress a compress format the size difference will be... small if not actually worse then the originial.

  • Setting different default locations for different file types in iTunes ?

    Point of this post is to find out if there is a way to have iTunes open tv and movie files from my time capsule and open music/music videos from my MacBook pro. I want to set up a network so any computer in the house can watch but have their own music library. Also even though I have 640 gb of space on my HD it's running out fast science I only have HD files I convert into m4v files. Is this possible or do I have to move all my iTunes to the time capsule and set that as the iTunes directory? When I had a PC it could pull up files from an external and from the laptop. Please tell me we didn't give pc's something we don't have.

    bump

  • 2 different files in the same location?

    When we upload files they go all in one folder.
    The first editor calls his graphic "Picture 1.png" (wonder where that came from..)
    Sure sometimes before the item gets deleted another one will upload an completly different picture with the same filename.
    The thing that it different between the 2 would be the Asset ID. So I was wondering if there is a way to make folders with asset IDs in the location where everybody uploads there stuff to.
    To tidy up on the long run I guess we just would need to delete the empty folders (as the content has been archived).
    How would I do this? How do other people deal with the same filenames for different files? It even happens within the same production so the solution to create an subfolder for each production (read this a while ago) does not work for us.
    I know that for future projects we will tell people to use more describing filenames (but even there: there might be two different kitchens called the same..) but I also talk about a huge, messy archive to migrate..
    thanks
    tobi

    Let me rephrase things a bit as I used the term Excel chart  to literally. We create charts in SSRS. We then use a query string that includes "rs:command=render&rs:format=Excel" to get the chart into Excel. The "chart" in Excel is really just an
    image and the associated data table is the cells filled in with the data. We then "select" the area that encompasses all of these objects and paste that into the PowerPoint slide.
    Our source folder structure is as follows (note that I while I am being generic, the Ecel file names are the same between folders:
    Folder A: File1.xls, File2.xls, File3.xls ..... File40.xls
    Folder B: File1.xls, File2.xls, File3.xls .....File40.xls
    This goes on for 8 folders but can be as many as 30
    The routine we use to create the xls file from the SSRS chart names the xls file and puts it in the correct folder.
    The idea was we would create a template chart set in PPT for folder A and then create copies of the PPT and change the links to point to Folder B, etc.
    We have ensured that all Excel Documents are closed when we try to do an update.
    We are also getting the following error and I'm paraphrasing: Cannot open multiple instances of a file of the same name even if it is in a different location. This occurs when doing an update links when we don't get the initial error message I listed first.
    If we change the names of the files in each folder: i.e. FolderAFile1.xls, FolderAFile2.xls, etc then we can do the update links. This is time consuming as the SSRS exports are done by the end users and we are the developers trying to create a reusable solution.
    One other issue we are seeing which I hope you can address is that when we are getting the update links to work, the process opens up each Excel file THREE times. It takes almost 15 minutes to update a PPT with 18 linked xls files.

  • Different links for different forms of the same list.

    Greetings,
    I have a custom list created with several columns one of which is the Title column. I have created three different views for this list.
    Using SharePoint Designer 2013 I have created three separate forms, one is a custom new for, a custom edit form and a custom display form. For specific reasons, I have not setup these forms as default. 
    I'd like to change the URL of the Title column depending on the view. 
    For example, if I am on View1 and click on the Title column, then I should see the custom display form I have built. In short, I want a way to manually change the url of the Title column. 
    I plan on creating several other forms for this same list and hence I need to know how I can change the URL of the Title column to match the need of the workflow.
    Thanks in advance.
    Daniel Christian (MCTS)

    May be you can achieve it using different java scipt for different views:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d7083056-594b-45b4-9fd4-9d615cdf5875/how-to-change-link-of-list-items-title-in-sharepoint-custom-list-by-programmatically-on-sharepoint?forum=appsforsharepoint
    However another suggest is that you create multiple title column with different links. every view will have a different title column so it can achieved.

Maybe you are looking for

  • Is PKCS#7 format supported by Mac OS X 10.6 to 10.7?

    Hi, Couple of questions on Mac OS X 10.6 to 10.7. 1) Can a Mac OS X 10.6 to 10.7 version supports PKCS#7 format for SSL certificate installation? 2) If PKCS#7 format is supported, is the file extension .p7b file? Thanks! J

  • Where to write default search message

    Hi guys I am searching a long to find where to write default search message on site search module. http://webmar.businesscatalyst.com/index When user click on the GO button next to the search box site search module must show a default message like yo

  • Hundreds of E-mail are being Sent without my knowledge.

    Hundreds of e-mail messages are being sent from my account without my knowledge.  Verizon is doing nothing.  I have complained 3 times.

  • Slideshow/CD/DVD?

    Hello: Is it possible to burn a slideshow created in iPhoto to CD, DVD, or transfer to a flashdrive? Thanks, Medren

  • Batch Audio "Overwrite All With Transition" problems

    I posted this thread a while back, and it was answered. http://discussions.apple.com/thread.jspa?threadID=1295905&tstart=0 I returned back to the thread because I'm doing the same thing months later, and I needed a reminder. But now when I do the exa