Reading unicode files

I have a problem reading unicode text files.
As written in books and that stuff i should use Reader instead of InputStream for this purpose. I do so and what i get is letters separated by \u0000 chars. So what is the way to convert unicode to "normal" strings. I deleted all the 00 using StringBuffer, but it don't work in older VMs, such as provided with win98.
So, what is the way-out?....the second problem going to be is writing unicode files:)

You have a file encoded using UTF-16, it sounds like. If you use a FileReader, let's say, that object will assume the file you are reading is encoded in your system's default encoding. Unfortunately that default is not going to be UTF-16, but something else like ISO-8859-1. To read a file using an encoding that you specify, do this:Reader r = new InputStreamReader(new FileInputStream(yourFile), "UTF16-BE");This will give you a reader that will probably work... although I don't know if your files are "big-endian" or "little-endian", so you might have to use "UTF16-LE" instead.
You can wrap that Reader in a BufferedReader if you like, that's generally more efficient for input processing. And to write your data in UTF-16, do the similar thing using an OutputStreamWriter with the same encoding. Check out the API documentation page for the java.io package; the line about InputStreamReader will have a link for either "encoding" or "charset" that will give you more information about UTF-16 and so on.

Similar Messages

  • Create unicode file and read unicode file

    Hi
        How can create a unicode file and open unicode file in LV
    Regards
    Madhu

    gmadhu wrote:
    Hi
        How can create a unicode file and open unicode file in LV
    Regards
    Madhu
    In principle you can't. LabVIEW does not support Unicode (yet)! When it will officially support that is a question that I can't answer since I don't know it and as far as I know NI doesn't want to answer.
    So the real question you have to ask first is where and why do you want to read and write Unicode file. And what type of Unicode? Unicode is definitly not just Unicode as Windows has a different notion of Unicode (16 Bit characters) than Unix has (32 Bit characters). The 16 Bit Unicode from Windows is able to cover most languages on this globe but definitly not all without code expansion techniques.
    If you want to do this on Windows and have decided that there is no other way to do what you want you will probably have to access the WideCharToMultiByte() and MultibyteToWideChar() Windows APIs using the Call Library Node in order to convert between 8 bit multybyte strings as used in LabVIEW and the Unicode format necessary in your file.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Read unicode file using java

    Hi all,
    I'm fairly new to java. In my program i need to read a Unicode file. (When i did it normal way it shows only "?" s for all the non English characters).
    can any one help me? (It better u can sent a simple example too)
    Thanks.
    regards,
    wijitha

    Use an InputStreamReader.

  • Reading unicode file using pure C++??

    Hi Guys,
    I need help reading a unicode/utf8 file using C/C++. Any pointers or sample code will be of great help.
    Thanks
    Gulshan

    See sections 20.2 and 20.3 of "The C++ Programming Language" 3rd ed. - by Bjarne Stroutrup.
    I'll go out on a limb and naively state that using wstring rather than string will take you a long way towards solving your problem, but you might have to play around with char_traits. The general usage of wstring should be identical to string, so I'm sure you can find many examples.
    ... Dave

  • Need to read Unicode in a file

    Hi,
    My need to read Unicode from a file (on a Windows box) is due to the fact my software is used in different countries and on different keyboard naturally. All the users are not computer literate but, like me, they are all lazy and want to put their username and password in a config file my application reads. If their username or password contain Unicode characters I have a problem reading.
    They are simple users that I would like to advise them to open the config file using Windows Notepad, then type in their username and password, and save the file as Unicode. Notepad has four ways to save a file, ANSI, Unicode, Unicode big endian, and UTF-8 (I've tried them all except ANSI of course). Saving a file in a different format is as complicated as I would like it to get for them, some will have trouble even with this.
    I read the file like so:
    BufferedReader rdr =
        new BufferedReader(
            new InputStreamReader(new FileInputStream(file_name), "UTF-16"));
    String line;
    while ((line = rdr.readLine()) != null) {
        String[] pieces = line.split("[=:]");
        if (pieces.length == 2) {
            if (pieces[0].equals("PASSWORD")) {
                byte[] possibleUnicode = pieces[1].getBytes("various encodings");
                pieces[1] = new String(possibleUnicode, "various encodings");
            propertyTable.setProperty(pieces[0], pieces[1]);
    }All reading is perfect except for a username or password which can contain a real multi-byte character. I have used many variations of converting the string I get into a byte[] using string_in.getBytes("various encodings tried") and then back to a string but nothing has worked.
    I tried a regular FileReader to a BufferedReader and that didn't work. I tried a FileInputStreamto a DataInputStream and that didn't work. I accomplished the most with what I described above, FileInputStream to InputStreamReader to BufferedReader.
    Does anyone know how to read Unicode in a file on a Windows file system?
    hopi

    I have used the byte conversion technique before
    successfully when I loaded a set of properties
    from a URL openStream(). The properties load()
    method takes an InputStream and assumes ISO-8859-1
    so I converted the bytes from ISO-8859-1 to UTF-8.
    Garbage characters were cleared up perfectly.I think you just got lucky that time. For characters up to U+007F, the UTF-8 encoding is the same as ISO-8859-1 (and most other encodings, for that matter). Characters in the range U+0080 to U+00FF will be encoded with one byte in ISO-8859-1, and with two bytes in UTF-8. In most cases, each of the two bytes in the UTF-8 representation will have values that are valid in ISO-8859-1. The decoded characters will be incorrect (and there will be too many of them), but they effectively preserve the original byte values, making it possible for you to re-encode the characters and then decode them correctly. But there's a big gap in the middle where the UTF-8 bytes produce garbage when decoded as IS)-8859-1. Run the included program to see what I mean.
    I don't know what's going wrong with your application, but I do know that changing the encoding retroactively is not the solution. I also think you're right about asking users save files in a certain encoding. Considering how much trouble programmers have with this stuff, it's definitely too much to ask of users.
    import java.awt.Font;
    import javax.swing.*;
    public class Test
      public static void main(String... args) throws Exception
        JTextArea ta = new JTextArea();
        ta.setFont(new Font("monospaced", Font.PLAIN, 14));
        JFrame frame = new JFrame();
        frame.add(new JScrollPane(ta));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        StringBuilder sb = new StringBuilder();
        for (int i = 0xA0; i <= 0xFF; i++)
          sb.append((char)i);
        String str1 = sb.toString();
        byte[] utfBytes = str1.getBytes("UTF-8");
        String str2 = new String(utfBytes, "ISO-8859-1");
        for (int i = 0, j = 0; i < str1.length(); i++, j += 2)
          char ch = str1.charAt(i);
          byte b1 = utfBytes[j];
          byte b2 = utfBytes[j+1];
          String s1 = Integer.toBinaryString(b1 & 0xFF);
          String s2 = Integer.toBinaryString(b2 & 0xFF);
          char ch1 = str2.charAt(j);
          char ch2 = str2.charAt(j+1);
          ta.append(String.format("%2c%10s%10s%3x%3x%3c%3c\n",
              ch, s1, s2, b1, b2, ch1, ch2));
        frame.setSize(400, 700);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

  • Reading Unicode data from a file...

    I am writing an application that needs to read some configuration data from a file. An end user edits the configuration file to provide the configuration data. The Java code reads this file and uses the configuration data supplied by the user.
    The user can also save non-ascii characters as part of the configuration data. hence, I do not want to use java properties files. What are the other options available that allow me reading Unicode data into my Java code and will also allow user to save the configuration file as Unicode?

    Java characters are Unicode characters. Read file data that consists of Unicode characters as Java characters or strings.
    You can read the data as primitive char values using the DataInputStream class. The InputStreamReader class can also read Unicode (UTF-16) data.
    Data can be written using the OutputStreamWriter class.

  • Reading TemSe files in unicode system showing greek letters

    Hi Gurus,
    I am facing issue with the newly converted unicode (cp 4102) spool files. I am using the standard functions RSTS_OPEN_RLC , RSTS_READ and RSTS_CLOSE to read TemSe files and create output files on application server using OPEN DATASET and TRANSFER.
    After conversion to unicode, these function calls are returning some greek characters with size of the itab doubled (and that is due to double-byte UTF-16 charcter set) .
    The program generates
    Runtime Error          CONVT_CODEPAGE
    Except.                CX_SY_CONVERSION_CODEPAGE
    " While a text was being converted from code page '4102' to '1100', on
    the following occurred:
    - an character was discovered that could not be represented in one o
    the two code pages;
    - the system established that this conversion is not supported."
    the statement
    TRANSFER TEMSE_DATA TO ACT_FILE
    generates this error.
    Can someone tell me what is missing ?
    TIA
    Wasim

    The extra characters are pasted below:
    ㄀  㤀㄀    ㈀㈀㄀㐀㄀ ㈀㜀㐀㐀㐀  㤀 ㈀ 㘀 㤀㈀ 圀 㤀㐀㄀ ㄀唀⸀匀⸀ 䈀䄀一䬀
    These kind of characters are also visible in SP11 contents for spool files.
    Again the question: which font to you use to display in your SAPGUI?
    The spool files are generated through language EN and should not show any non-english characters.
    That doesn´t tell anything. One advantage of Unicode is that you can enter, display and modify all languages/characters with an English logon.
    Another question: What technology is generating those spool files? Sapscript? Smartforms? Self written program?
    Markus

  • Read/Write file in Unicode (UTF-16)

    Hi, I have some issue to write a file in Unicode (UTF-16)
    I have to read a file with LabView, change some parameters and write the new data into the same file. The file uses Unicode UTF-16.
    I downloaded some library here: https://decibel.ni.com/content/docs/DOC-10153
    I can read the file, convert the data to UNI/ASCII/UNI, and then write the file. But when I open the new file with an editor like Notepad++ there are some unexpected characters at the end of the line.
    Even reading the file and writing exactly the same data doesn'not work.
    I attached an example.
    Thanks for you kind support.
    Solved!
    Go to Solution.
    Attachments:
    TEST.zip ‏7 KB

    Right-click on your Read and Write Text File functions.  There is an option to "Convert End Of Line".  Turn that off on both functions.
    As a side not, you don't need the Close File functions.  The Read and Write Text File functions will close the file if the file reference output is not wired.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Special characters being read from the unicode file for greek language

    Hi All,
    I have a report which would upload a unicode file and then update the vendor master data accordingly.
    The file contains greek characters too.
    when the file is being read in the code, some special characters are being added up to the vendor number which is the first entry. The special characters are not included in the file , but are added up only to the first vendor number and not any other vendor numbers.
    The logic that is being used is as follows :
    TRY.
          IF unicode IS INITIAL.
            IF codepage IS INITIAL.
    *-->      For backward compatibility where this FM might be called from
    *         other dependent objects (FMs/dynamic subroutines)
    *         which donot have access to  user's input w.r.t Unicode parameters
              OPEN DATASET filename FOR INPUT
                   IN LEGACY TEXT MODE
                   MESSAGE msg
                   REPLACEMENT CHARACTER repl_char
                   IGNORING CONVERSION ERRORS
                   FILTER filter.                         
            ELSE.
    *--> System in non-unicode and Unicode Environment (Phases I and II)
              OPEN DATASET filename FOR INPUT
                   IN LEGACY TEXT MODE CODE PAGE codepage MESSAGE msg
                   REPLACEMENT CHARACTER repl_char
                   IGNORING CONVERSION ERRORS
                   FILTER filter.                          
            ENDIF.
          ELSE.
    *-->  Extract File in Unicode format - Phase III
            OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING UTF-8
            MESSAGE msg
            FILTER filter.                                 
          ENDIF.
          IF sy-subrc NE 0.
            MESSAGE e001(zuni) WITH filename sy-subrc
             RAISING file_open_error.
          ENDIF.
    the unicode parameters used are : codepage = 8000.
    An early reply is most appreciated.
    Regards,
    Manu.

    Please check SAP notes for Eastern European Characters in Unicode system. and may be below code helps you
    DATA:
        ltp_bom                  TYPE sychar01,
        ltp_encoding             TYPE sychar01,
        ltp_codepage             TYPE cpcodepage.
    Processing --------------------------------------------------------- *
      TRY.
          CALL METHOD cl_abap_file_utilities=>check_utf8
            EXPORTING
              file_name         = itp_filename
              max_kb            = -1
              all_if_7bit_ascii = abap_true
            IMPORTING
              bom               = ltp_bom
              encoding          = ltp_encoding.
        CATCH cx_sy_file_open .
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING file_open_error.
        CATCH cx_sy_file_authority .
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING file_authority_error.
        CATCH cx_sy_file_io .
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
                  RAISING file_io_error.
      ENDTRY.
      CASE ltp_encoding.
        WHEN cl_abap_file_utilities=>encoding_utf8
          OR cl_abap_file_utilities=>encoding_7bit_ascii.
          CASE ltp_bom.
            WHEN cl_abap_file_utilities=>no_bom.
              OPEN DATASET itp_filename FOR INPUT IN TEXT MODE
                ENCODING UTF-8.
            WHEN cl_abap_file_utilities=>bom_utf8.
              OPEN DATASET itp_filename FOR INPUT IN TEXT MODE
                ENCODING UTF-8
                  SKIPPING BYTE-ORDER MARK.
            WHEN cl_abap_file_utilities=>bom_utf16_be.
              ltp_codepage = '4102'.
              OPEN DATASET itp_filename FOR INPUT IN LEGACY BINARY MODE
                BIG ENDIAN CODE PAGE ltp_codepage.
            WHEN cl_abap_file_utilities=>bom_utf16_le.
              ltp_codepage = '4103'.
              OPEN DATASET itp_filename FOR INPUT IN LEGACY BINARY MODE
                LITTLE ENDIAN CODE PAGE ltp_codepage.
            WHEN OTHERS.
              OPEN DATASET itp_filename FOR INPUT IN TEXT MODE
                ENCODING UTF-8.
          ENDCASE.
        WHEN OTHERS.
          OPEN DATASET itp_filename FOR INPUT IN LEGACY TEXT MODE.
      ENDCASE.
    Edited by: Nilesh Shete on May 7, 2010 5:29 PM

  • How to read UNICODE text file

    Dear Guru,
    Are there any function module that we can use to upload/read UNICODE text file?
    Please advice.
    Regards,
    Ari

    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                = filenam
        filetype                = 'ASC'
        has_field_separator     = 'X'
      TABLES
        data_tab                = in_rec
      EXCEPTIONS
        file_open_error         = 1
        file_read_error         = 2
        no_batch                = 3
        gui_refuse_filetransfer = 4
        invalid_type            = 5
        no_authority            = 6
        unknown_error           = 7
        bad_data_format         = 8
        header_not_allowed      = 9
        separator_not_allowed   = 10
        header_too_long         = 11
        unknown_dp_error        = 12
        access_denied           = 13
        dp_out_of_memory        = 14
        disk_full               = 15
        dp_timeout              = 16
        OTHERS                  = 17.

  • Reading unicode text file

    I could not find a VI to read unicode text files - this one reads unicode on the assumption that it contains plain text.  Might help someone struggling with unicode text files produced by some applications.  Enhancements welcome.
    James T

    Possible.  You just want to be able to read them? see attached image. Well for windows anyway.
    Message Edited by Stradis on 08-23-2007 01:07 AM
    Paul <--Always Learning!!!
    sense and simplicity.
    Browse my sample VIs?
    Attachments:
    Example_BD.png ‏10 KB

  • Problem While reading a file in text mode from Unix in ECC 5.0

    Hi Experts,
    I am working on Unicode Upgrade project of ECC5.0.
    Here i got a problem with reading a file format which it does successfully in 4.6 and not in ECC5.0
    My file format was as follows:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    It was successfully converting corresponding field values in 4.6:
    *4
    00000186
    2004
    06
    03
    00000010
    25
    0
    4
    0
    54.75
    0
    54.75
    0.00
    While i am getting some problem in ECC5.0 during conversion of the above line:
    *4 000001862004060300000010###/#######L##########G/##########G/########
    it was consider in the same # values.
    I have used the following statement to open and read dataset.
    OPEN DATASET i_dsn IN LEGACY TEXT MODE FOR INPUT.
    READ DATASET i_dsn INTO pos_rec.
    Thanks for your help.
    Regards,
    Gopinath Addepalli.

    Hi
          You might be facing this problem because of uni code. So while opening or reading the file, there is a statement call ENCODING. Use that option and keep the code page which you want. Then the problem may be solved.
    Thanks & Regards.
    Harish.

  • What are the commands available to read a file from application server and

    What are the commands available to read a file from application server and store the file into an internal table?

    Hi,
    To read a file from an Application Server to an Object there is a command in ABAP called <b>READ DATASET</b>. After that file is transported to that object you have to do a loop and put that data in an Internal Table.
    This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.
    For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.
    In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.
    If the file has not yet been opened in anon-Unicode program, it will be implicitly opened as a binary file for read access using the statement
    OPEN DATASET dset FOR INPUT IN BINARY MODE.
    . If a non-existing file is accessed, an exception that can be handled can be triggered.
    Influence of Access Type
    Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.
    Influence of the Storage Type
    The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.
    If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.
    If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.
    If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.
    System Fields
    sy-subrc Meaning
    0 Data was read without reaching end of file.
    4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
    Thanks,
    Samantak.
    <b>Rewards points for useful answers.</b>

  • Upload unicode file and display content in a textarea

    Hi all,
    I am trying to do the following;
    1. upload a unicode file (file with some non-english characters)
    2. after uploading, read the uploaded file and show the content in a textarea in a jsp page.
    I use struts in my project. I use class org.apache.struts.upload.FormFile for uploading the file. The upload works fine. I do the upload with help of FormFile's getInputStream method. When i read and display the content in the textarea, the content is displayed junk. But i tried to open the uploaded file, its fine. I mean it is just as my source file. Please help me out for reading the uploaded unicode and displayed in a textarea.
    Below is the code that i use to upload the file;
    File tempFile = null;
    FileOutputStream fos = null;
    InputStream is = null;
    try {
         tempFile = "c:/ThaiText.txt";
         fos = new FileOutputStream(tempFile);
         is = theFile.getInputStream();
         // Transfer bytes from in to out
         byte[] buf = new byte[1024];
         int len;
         while ((len = is.read(buf)) > 0) {
              fos.write(buf, 0, len);
         logger.info("fileName$$=" + tempFile.getName());
    } catch (Exception e) {
            logger.error(e);
         throw e;
    } finally {
         closeOutputStream(fos);
    }Below is the code that i use for reading the uploaded file's content and store it to a string. I set this string to a form bean's string property.
    public static String readContentNonUTF8(String path) {
         FileInputStream fis = null;
         String value = "";
         try {
              fis = new FileInputStream(path);
              byte[] buf = new byte[1024];
              int len;
              while ((len = fis.read(buf)) > 0) {
                   String tmp = new String(buf, 0, len);
                   value = value.concat(new String(tmp.getBytes()));
         } catch (Exception e) {
              logger.error(e);
         } finally {
              try {
                   fis.close();
              } catch (Exception e) {
         return value;
    }

    Hi,
    Thanks for your reply. You meant that both method also can used to upload file and submit data? How about if i want to use the first method to upload file and submit data? How can i upload the file by using first method?

  • Problem with compressing unicode file names in zip file

    Hi Everyone,
    I have a problem while compressing the unicode file name in a zip file. I used the below code for compressing the unicode files.
    String[] source = null;
    // C:\\TestData\\unicode_filename.txt :  unicode_filename.txt is the file created in japanesse language
    source = new String[] {"C:\\TestData\\temp_properties.xml","C:\\TestData\\unicode_filename.txt" };
    byte[] buf = new byte[1024];
    // Create the ZIP file
    String target = "C:\\TestData\\target.zip";
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target));
    // Compress the files
    for (int i = 0; i < source.length; i++)
         FileInputStream in = new FileInputStream(source);
         // Add ZIP entry to output stream.
         String fileName;
         File tempFile;
         ZipEntry zipEntry = new ZipEntry(source[i]);
         fileName = zipEntry.getName();
    zipEntry = new ZipEntry(fileName);
    zipEntry.setMethod(ZipEntry.DEFLATED);
    getUTF8Bytes(source[i]);
    // here I'm unable to find the unicode files and not able to understand.
    out.putNextEntry(zipEntry);
    // Transfer bytes from the file to the ZIP file
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    // Complete the entry
    out.closeEntry();
    in.close();
    // Complete the ZIP file
    out.close();Please help me how to fix this issue.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    Thanks for your time for looking into my query.
    Please check the below code for debugging the issue and throw your comments/suggestions for fixing the issue.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    public class ZipTest
      public static void main(String[] args) {
              String[] source = new String[] {"C:\\TestData\\APP_Properties.xml","C:\\TestData\\??.txt" };
              byte[] buf = new byte[1024];
              try {
                   // Create the ZIP file
                   String target = "C:\\TestData\\target.zip";
                   ZipOutputStream out = new ZipOutputStream(new FileOutputStream(target));
                   // Compress the files
                   for (int i = 0; i < source.length; i++) {
                        FileInputStream in = new FileInputStream(source);
                        // Add ZIP entry to output stream.
                        String fileName;
                        File tempFile;
                        ZipEntry zipEntry = new ZipEntry(source[i]);
                        fileName = zipEntry.getName();
                        zipEntry = new ZipEntry(fileName);
                        zipEntry.setMethod(ZipEntry.DEFLATED);
                        getUTF8Bytes(source[i]);
                        out.putNextEntry(zipEntry);
                        // Transfer bytes from the file to the ZIP file
                        int len;
                        while ((len = in.read(buf)) > 0) {
                             out.write(buf, 0, len);
                        // Complete the entry
                        out.closeEntry();
                        in.close();
                   // Complete the ZIP file
                   out.close();
              } catch (IOException e) {
                   e.printStackTrace();
         private static byte[] getUTF8Bytes(String s) {
              char[] c = s.toCharArray();
              FileOutputStream file;
              try {
                   file = new FileOutputStream("C:\\TestData\\output.txt", true);
                   int len = c.length;
                   // Count the number of encoded bytes...
                   int count = 0;
                   for (int i = 0; i < len; i++) {
                        int ch = c[i];
                        if (ch <= 0x7f) {
                             count++;
                        } else if (ch <= 0x7ff) {
                             count += 2;
                        } else {
                             count += 3;
                   // Now return the encoded bytes...
                   byte[] b = new byte[count];
                   int off = 0;
                   for (int i = 0; i < len; i++) {
                        int ch = c[i];
                        if (ch <= 0x7f) {
                             b[off++] = (byte) ch;
                             file.write((byte) ch);
                        } else if (ch <= 0x7ff) {
                             b[off++] = (byte) ((ch >> 6) | 0xc0);
                             file.write((byte) ((ch >> 6) | 0xc0));
                             b[off++] = (byte) ((ch & 0x3f) | 0x80);
                             file.write((byte) ((ch & 0x3f) | 0x80));
                        } else {
                             b[off++] = (byte) ((ch >> 12) | 0xe0);
                             file.write((byte) ((ch >> 12) | 0xe0));
                             b[off++] = (byte) (((ch >> 6) & 0x3f) | 0x80);
                             file.write((byte) (((ch >> 6) & 0x3f) | 0x80));
                             b[off++] = (byte) ((ch & 0x3f) | 0x80);
                             file.write((byte) ((ch & 0x3f) | 0x80));
                   file.write((byte) '\n');
                   file.write((byte) '\r');
                   file.flush();
                   file.close();
                   return b;
              } catch (FileNotFoundException e1) {
                   e1.printStackTrace();
              } catch (IOException e1) {
                   e1.printStackTrace();
              return null;
    }Thanks
    Aravind                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • IP: query shows only open request data, when filtered

    Hi, I can see only data of the open request. but it depends on the filter. I have a real-time provider with closed requests and one open request. (The closed requests come from manually switching between planning and loading mode.) On top there is a

  • How to clear UWL items ?

    Hi, We are having so many entries or pending tasks in UWL of each user . How to clear them ? And I did not find any delete or remove button by selecting any entry . How to delete those entries one by one and all entries at once ? Thanks, Surya

  • [SOLVED] Problem copying objects in Inkscape 0.48.0-4

    I have problems when I copy any object when using inkscape. Even after removing the config directories and using a completely blank document. I create a simple rect and press ctr+c (or use the context menu) and this error comes up: El script inkex.py

  • [SOLVED] Getting theme errors after a recent upgrade in gtk3 apps

    I have recently started getting errors like these after a recent upgrade. (nautilus:12329): Gtk-WARNING **: Theme parsing error: *-*:*:*: Not using units is deprecated. Assuming 'px'. Full error while opening nautilus can be see here. http://sprunge.

  • Artwork for playlists (iTunes 10)

    Am I missing something ? iTunes 10 has a new button to show a list window, with artwork. If I select my whole music library, this works (but only after going Menu, View, Always Show Artwork). But if I select a playlist and click it, I get a list with