Streaming out a zipped file

I am interested in unzipping a binary file (pdf) and stream it out to a user via a servlet. If possible, I do not want to make a hard copy of the file on the server when it is unzipped. My Servlet code would start like this:
PrintWriter out = res.getWriter();
res.setContentType("application/pdf");
//unzip a file and stream it out.
How could I approach this / Is this possible?
Thanks very much in advance.

I think you should use package java.util.zip.
There are classes ZipInputStream and ZipEntry.
Try to play with them.
E.g.:
OutputStream out = ... // writes bytes into HTTP-Body
ZipInputStream in = new ZipInputStream(
  new FileInputStream("file.pdf.zip")
while(in.available() > 0) {
  out.write(in.read());
}

Similar Messages

  • Problem when streaming out a binary file

    Hi,
    I am trying to stream out a binary file to an output stream (not a file, but a socket). My file is a gzip file, and I was initially simply trying to open the
    file, read it to a a byte array, and writing it out to my output stream. However, I got corrupted data at my other end and it took me quite a bit of
    debugging hours to find out why.
    I tried writing to a file the same information I was writing to my output stream but, although my file was correct, my output stream still contained
    corrupted data.
    I think I have finally narrowed down my problem to the fact that when I try to write a 0x00 value to my output stream, everything gets ignored from this
    point until I write a 0x0a byte to my output stream. Obviously this produces corrupted data, since I need all the bytes of my binary file.
    If somebody can direct me as to how to write a 0x00 value to a socket output stream, I would really appreciate your input.
    This is a sample of my code (Right now I am writing byte by byte: not very efficient, but was the only way I found where I was getting a problem):
    // out is of type OutputStream
    if (Zipped){
         // In this case we just have to stream the file out
    File myFile = new File(fileName);
         FileInputStream inputFile = new FileInputStream(myFile);
         FileOutputStream fos = new FileOutputStream(new File("/tmp/zip.gz")); //zip.gz results in a good (not corrupted) file.
         ByteArrayOutputStream out1 = new ByteArrayOutputStream(1024);
         int bytes = (int)myFile.length();
         byte[] buffer = new byte[bytes];
         bytes = inputFile.read(buffer);
         while (bytes != -1) {
              out1.write(buffer,0,bytes);
              bytes = inputFile.read(buffer);
         inputFile.close();
         try {
              int count=0;
              bytes=out1.size();
              while (count<bytes){
                   fos.write(buffer,count,1);
    out.write(buffer,count,1); // when buffer[count] == 0x00, everything after it gets ignored until a 0x0a byte is written.
                   count++;
         } catch (IOException ioe) {
              SysLog.event("IOEXCEPTION: "+ioe);
         } catch (Exception e) {
              SysLog.event("EXCEPTION: "+e);
         fos.flush();
         fos.close();
         out.flush();
    out.close();
         return;
    }

    Actually, I had thought about that and for some time I tried getting rid of some of the header information in the gzipped file, and then I stopped doing that when I realized that part of the gzipped file is a CRC value which I believe is computed taking into account both the data of the file and the header information. If this is the case, then getting rid of part of the header would produce a corrupted file ... but then, I might be wrong in this issue.
    Anyway, to make my application more clear, what I am doing is writing the code for a cgi command which is suppossed to access information from a database, create an xml file, gzip it, and then send it to the client who requested the information.
    Therefore, what I am sending is an xml file (Content-Type: text/xml) in compressed format (Content-Encoding: gzip). Note that if I don't gzip the file and then send it uncompressed to the client, I have no problems. However, for me it is very important to gzip it because the size of the file can get very large and that would just take bandwidth unnecessarily.
    On the other hand, if I try to gunzip the file locally, I have no problem either (the file is not corrupt at the server's end). Therefore, my problem is when I stream it out.
    Any further help would be really appreciated!

  • Read Zip File and output it to the Stream

    Hi,
    I really need help with this topic. I need to write a function which as input read the zip file (inside: jpeg, mp3, xml)
    and as output provide the output Stream of this zip file.
    public OutputStream readZipToStream(String sourceZipFile) { ....}
    I've tried something....
    public static OutputStream    readZipToStream(String src, HttpServletResponse response) throws Exception {
            File fsrc = null;
            ZipOutputStream out = null;
            byte buffer [] = null;
            FileInputStream in = null;
            try {
                buffer = new byte[BUFFER_CREATE];
                fsrc = new File(src);
                out = new ZipOutputStream(response.getOutputStream());
                ZipEntry zipAdd = new ZipEntry(fsrc.getName());
                zipAdd.setTime(fsrc.lastModified());
                out.putNextEntry(zipAdd);
                // Read input & write to output
                in = new FileInputStream(fsrc);
                while (true) {
                    int nRead = in.read(buffer, 0, buffer.length);
                    if (nRead <= 0)
                        break;
                    out.write(buffer, 0, nRead);
                out.flush();
                in.close();
            } catch (IOException ioe) {
                logger.error("Zip Exception: " + ioe.getMessage());
                ioe.printStackTrace();
                throw ioe;
            return out;
        } But the problem with this code when it returns ( I called from servlet: bellow)
    it ask user to save the file as servlet.jsp file. So I would have to rename it to zip file later.
    What I want to achive is it would ask to save zip file from the stream as name of the original zip file (if that is possible)
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%
    OutputStream stream = null;
    response.setContentType("application/zip");
    target = mount_media + File.separator + "test_swf.zip";       
    try {
    stream = ZipUtil.readZipToStream(target, response);
    } catch (Exception ex) {
            System.out.println(ex.getMessage());
        } finally {
    if(stream != null) {
                stream.close();
    %>
    <%@page import="java.io.File" %>
    <%@page import="java.io.OutputStream" %>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    </body>
    </html>

    Hi oleg_s ,
    There's a contradiction of content in your JSP :
    response.setContentType("application/zip");
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">The html part of your JSP seems useless for what you mean to do. Therefore, instead of a JSP, you should use a simple servlet to send your zip file.

  • Validating Corrupted ZIP Files

    I need to validate zip files whether they are corrupted or not.
    Can anybody help me in validating zip files(corrupted or not).
    Thanks.
    Annapurna

    Jar-files are created by using a checksum. I think, this checksum is proofed, if you extract the jar-file by means of java. So there will be an exception if an entry of this file is corrupted.
    Have you had a look at the java-sources for finding out, if zip-files use the the same mechanism?

  • Zip file out of binary (xstring)

    Hi,
    I try to compress (zip) binary data (for example a picture) and then give it to a html page. I use the cl_abap_gzip=>compress_binary method and it seems to work. But when I save the zip-file to harddisk over the popup at the html - page, the file could not be opened. WinZip says that it is an unvalid archive.
    Can anybody help me?
    Here my example coding at the OnInitialization Event of the business server page:
    * event handler for data retrieval
    * local variables
    DATA: xsourcefile TYPE xstring.
    DATA: xzippedfile TYPE xstring.
    DATA: source_file_mime_type TYPE string.
    DATA: xzippedcontentlength TYPE i, xzippedcontentlengthstring TYPE
    string.
    * References
    DATA: o_mime_api TYPE REF TO if_mr_api.
    * processing
    * +++ Read File from MIME-Repository (binary) +++
    CALL METHOD cl_mime_repository_api=>if_mr_api~get_api
      RECEIVING
        r_mr_api = o_mime_api.
    CALL METHOD o_mime_api->get
      EXPORTING
        i_url              = 'SAP/ZGSD_SD_ADIS/test.gif'
    *    I_CHECK_AUTHORITY  = 'X'
      IMPORTING
    *    E_IS_FOLDER        =
        e_content          = xsourcefile
        e_mime_type        = source_file_mime_type
    *    E_LOIO             =
    *  CHANGING
    *    C_LANGUAGE         =
      EXCEPTIONS
        parameter_missing  = 1
        error_occured      = 2
        not_found          = 3
        permission_failure = 4
        OTHERS             = 5
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    * +++ create ZIP-File +++
    TRY.
        CALL METHOD cl_abap_gzip=>compress_binary
          EXPORTING
            raw_in                     =  xsourcefile
    *    RAW_IN_LEN                 = -1
    *    COMPRESS_LEVEL             = 6
          IMPORTING
            gzip_out                   = xzippedfile
            gzip_out_len               = xzippedcontentlength.
    * ... Länge Casten !
        xzippedcontentlengthstring = xzippedcontentlength.
    * ... Errorhandling
      CATCH cx_parameter_invalid_range . " Error-Handling
      CATCH cx_sy_buffer_overflow . " Error-Handling
      CATCH cx_sy_compression_error . " Error-Handling
    ENDTRY.
    * +++ Put ZIP-File in Response +++
    response->set_data( xzippedfile ).
    response->set_header_field( name  = if_http_header_fields=>content_type
              value = 'application/octet-stream' ).
    response->set_header_field( name  =
    if_http_header_fields=>content_length
              value = xzippedcontentlengthstring ).
    response->set_header_field( name  = 'Content-Disposition'
    value = 'inline;filename=test.zip' ).
    navigation->response_complete( ).
    Thanks Timo

    I was on vaca, sorry for the late reply.
    I can't see the video card but from what I see on the rest of the spec, those stats are extremely low.
    An OS (especially modern) consumes 700~1GB RAM itself. Depending on the video cards amount of RAM, if it requires using RAM, you already only have around 1GB to share. So your hard disk will be thrashed on a system like that struggling to keep RAM managed.
    The CPU is very slow, in the value line. You can look on several sites which measure various components to see where you fall for performance. For example, Passmark (fairly reliable at quick glance) puts your CPU in the mid to low (value) range and has a score of 808. A mid to high end, standard CPU these days (~$300 range) is around 10,000 and above:
    http://www.cpubenchmark.net/midlow_range_cpus.html
    1.7GHz is pretty slow and without any Intel-esque turbo boost, the CPU is really going to be sluggish.
    I would say that laptop is designed to read email and surf the web. I think it would even struggle to play HD video, let alone render real-time modern Canvas 2d animation with any level of consistency. If you do "anything else" while the animation happens, or if the animation is fairly layered, this machine will bog down. It should be entirely visible in your task managers performance tab. Most likely you'll see the CPU peg out at 100% and memory not far behind it. Take a glimpse.
    I think your entire issue is that computer, not CanvasJS/EdgeJS differences.

  • I dont have a internet connection at home, i connect my iphone 5 to my computer, it says i need new version of ITunes 11.2, i cant download it with out internet, i am at Library can i get ITunes 11.2 in a zipped files or exe file downloaded to my usb driv

    i dont have a internet connection at home, i connect my iphone 5 to my computer, it says i need new version of ITunes 11.2, i cant download it with out internet, i am at Library can i get ITunes 11.2 in a zipped files or exe file downloaded to my usb driv

    i can take pictures off my phone but thats it, i have some nice programs for pictures and art work and cant get them back on my phone to send them to friends and family. Also have some OLD pictures of Family on this Computer that was given to me i want to get off of it and send out but i can dragg and dropp from phone to computer but i cant drag and drop onto phone from computer and there the same jpg files, sad. i like my iphone5 and want another one but i might have to change when it time to upgrade , i dont want to, but i cant afford internet let alone a mac or pc, this one was given to me, was lucky to have saved to get the phone and service on a family plan, i have unlimited internet on phone that is my life source for internet, wish io could afford both phone and internet, its phone or internet, and with phone i have both in a way

  • Request time out - zip file processing in sharepoint 2010

    Hello All,
    I have developed web part that uploads the zip package file and then programmatically zip will extracted and all files will uploaded to picture library.
    If zip files are larger then it gets request timed out error..in production server.
    Currently in web.config executionTimeout="600". I can not increase it on production server so comfortably...
    However, with this same settings functionality works well in QA and dev environment.
    How to find the proper justification for this... I do not have access to any of the environment.
    Thanks,
    Saumil

    if it will take long time it's better to do this process asynchronously using Async application Page , also you might need to check the request length as well
    check the asynchronous page example
    http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
    Hope that helps|Amr Fouad|MCTS,MCPD sharePoint 2010

  • Setting the name of streamed zip file

    Hi,
    I have a servlet which creates a zip file with documents retrieved from a database. To create the zip file I am using the ZipOutputStream class and adding the documents one at a time to this object. This is all working fine.
    The problem I have is pretty simple, in that I can't seem to find a way in which to set the name of the zip file. This must be possible! At the moment it appears to be setting the name of the zip file to the name of the class that created it. In this case my class is called DocumentPacker and what comes back from the servlet is a zip file called DocumentPacker.zip. This wouldn't be so bad, but if you're creating the zip file for a user that does not have cookies enabled, it appends the session id to the end of the zip file name which i don't want.
    I am creating my ZipOutputStream like this:
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
    and then adding the documents one at a time using a BufferedInputStream.).
    Any help on how to set the name would be much appreciated
    Thanks
    Claire

    Your servlet must set some headers on the HTTP response (Content-Type as "application/zip", Content-Disposition as "attachment; filename=yourfilename.zip")
    Read the RFC1806 document.
    Content-Type: application/zip
    Content-Disposition: attachment; filename=genome.jpeg

  • How does System.out.println(). Work inside src.zip file !

    Hello guyz,
    I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code. But could not understand it. As written i remember
    "out is an object encapsulated in the System class."
    Thats ok. But i could not understand the code.
        public final static PrintStream out = nullPrintStream();
        private static PrintStream nullPrintStream() throws NullPointerException {
         if (currentTimeMillis() > 0) {
             return null;
         throw new NullPointerException();
        }Also when i ran the DJ Decompiler it decompiled it to this:
    public class One
         public static void main(String args[])
              System.out.println("hello world");
    import java.io.PrintStream;
    public class One
        public One()
        public static void main(String args[])
            System.out.println("hello world");
    }Also, why does it need to import PrintStream ?

    Peter__Lawrey wrote:
    I was just wondering how System.out.println() worked so i opened up the src.zip file and checked the source code.This value is a place holder. This value is changed as soon as enough of the JVM is initialised for printing to work.
    Also, why does it need to import PrintStream ? It doesn't, but it is used in the code so DJ is including it just in case.Sorry,
    But i don't understand at all.

  • Like to understand - Stream DataSet (of XML data) to ZIP file?

    i have similar kind of requirement where i need to save dataset data in multi part zip file. from this site i got a sample code
    .NET - Stream DataSet (of XML data) to ZIP file? but few area is not clear.
    the sample code as follows
    // get connection to the database
    var c1= new System.Data.SqlClient.SqlConnection(connstring1);
    var da = new System.Data.SqlClient.SqlDataAdapter()
    SelectCommand= new System.Data.SqlClient.SqlCommand(strSelect, c1)
    DataSet ds1 = new DataSet();
    // fill the dataset with the SELECT
    da.Fill(ds1, "Invoices");
    // write the XML for that DataSet into a zip file (split into 1mb chunks)
    using(Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
    zip.MaxOutputSegmentSize = 1024*1024;
    zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
    zip.Save(zipFileName);
    how this word code Ionic they are using dotnet zip library ? tell me what is
    Ionic
    i guess this line zip.MaxOutputSegmentSize = 1024*1024; means each segment size would be 1mb ? am i right ?
    this line is not clear
    zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) );
    what is the meaning of this (name,stream) stream never declared but how they can use ?
    tell me what is the meaning of this line zip.AddEntry(zipEntryName, (name,stream) => ds1.WriteXml(stream) ); what the code will do reading the above statement.
    suppose if the above code save dataset data in 5 separate zip file then what name will be used for each segment?
    if possible give me the code which will read all segment file and extract its content in a folder. thanks

    Ionic is a 3rd party library which can be download by click on the shortcut where you got the code.  I don't recommend using compiled 3rd part software unless the source code is provided.  Codeplex solutions are usually very reliable.
    Yes 1024 x 1024 is the 1mbyte size of the stream
    The library is using a Linq syntax.  So  simple Linq uses something like this
    .Select(x => x.ToString())  Where x is a variable name that can be any letter(s) you choose.  Select is part of an enumeration.  It is really just a shortcut instead of using a "FOR" statement.
    The line zip is more complicated version of Linq.  It is using two parameters (name,stream).  I don't think the code actually works and you would have to look at the documentation at the codeplex website.
    jdweng

  • Is there a program out there that will repair .zip files in OS x?

      i have a zip file that i cant open i get a crc error.Is there a program out there that will repair .zip files in OS x?

    Klaus1 wrote:
    its a movie taken on i movie.
    iMovie projects do not like being zipped. Unless you have the unzipped original you will have to create the project again.
    Furthermore there's probably no point in trying to zip it.  Many media formats such as mp3, AAC, mp4, jpeg are already compressed and compressing again just adds overhead (making them bigger) as well as placing them in a format that is hard to recover anything from should something go wrong.

  • Download of .zip file causes 1)stream of 'untitled' tabs & 2)download win doesnt open - why?

    tried to download .zip files from Deitel.com and InformIT.com -- download worked in Internet Explorer, caused a stream of tabs L to R on the Firefox 3.6.8 browser screen, flickering download window, but no files were delivered -- waited 5 min. The tabs were labeled 'untitled'.
    Host system Windows 7 Home User.

    Firefox sometimes has this tab proliferation when there is a mixed signal about which program is supposed to handle the download, the browser or an external program. If you check here:
    Tools > Options > Applications
    then type zip in the search box and wait for it to filter...
    Make sure none of the items is supposed to be opened with Firefox.

  • I purchased creative lightroom presets. I see the zip file in my download file and I try to import to LR but it just keeps creating a bundle never giving me the option to import (greyed out). What am I doing wrong?

    I purchased creative lightroom presets. I see the zip file in my download file and I try to import to LR but it just keeps creating a bundle never giving me the option to import (greyed out). What am I doing wrong?

    Try unzipping the file first. I have no idea regarding your level of technical expertise so advanced apologies if this is really basic. A ZIP file is a compressed file containing one of more files within it. To access the files you will need to expand it. If you double-click on it first, it should open up for you. If it does not automatically expand, you can select the files and copy them to a new folder. The copy will unload them into an uncompressed form. Once they have been uncompressed, you should be able to import them.
    If the import is still giving you problems, go to your Preferences, click on the Presets tab and click the Show Presets Folder button. You can then copy your purchased presets into the folder shown. You will want to copy them to the User Presets subfolder.

  • Problem on windows xp with downloaded zip file

    Hi,
    I have written a JSP to download file which is as follows
    try
    response.setContentType("application/download");
    response.setHeader("Content-Disposition","attachment;filename=<FileName>");
    int iRead;
    FileInputStream stream = null;
    try
    File f = new File(<FilePath>);
    stream = new FileInputStream(f);
    while ((iRead = stream.read()) != -1)
    out.write(iRead);
    out.flush();
    finally
    if (stream != null)
    stream.close();
    catch(Exception e)
    //out.println("Exception : "+e);
    After downloading zip file, could not extract files on windows XP by using any tool or built-in extractor i.e. compressed(zipped)folders (error: compressed folder invalid or corrupted).
    But this works on win2k or win98
    How can i work with it or can anyone tell me a solution to handle such a problem.
    Thanks in advance.
    Rajesh
    [email protected]

    This could be a problem with the built-in ZIP program in Win XP - it's possible that the ZIP you are downloading (uploading?) is simply incompatible with the XP program. In Win 98 & 2000, you would have to use your own ZIP program, e.g. Winzip, and that can handle more formats that the XP program.
    Try installing the same ZIP program that you have on w98/2k on your XP machine, and see if you can open the uploaded file using it.

  • 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

  • Error building stand alone applicatio​n, with LV.7.01

    Hi to all.... I always get this pop up error (see picture attached) when trying to build a Stand alone application. I got the full version of Labview 7.01 and the Application builder also. the runtime engine is also 7.01. Regards HFZ. HFZ Solved! Go

  • Publishing Exchange coexistance in 2010/2013 in TMG

    I already asked this in the TMG forums and didnt really get the answers there, so hoping I get better luck here, so slightly rephrased: Environment: Two Windows 2008 R2, Exchange 2010 SP3 servers, currently holding all mailboxes Two Windows 2012 R2,

  • User exit for position of PO

    Hi Guru, I find a User exit that  acting on the positions on the Purchase Order. This should exit afford to act on the calculation of net value of Purchase Order. Help me. Best regards Michele

  • HT4528 My iPhone 4s isnt working correctly

    My iphone 4s is not turning on. When I conect it to my Macbook it conects but when I click restore it gives me the code 1600. Now my iPhone will come on but either to an apple screen or just a white screen that has nothing else on it. I need help, wh

  • Copy applications between schemas

    Hi, we have an application with several forms built on tables. Now we want to copy all info in this schema (tables, forms, packages...) to another schema. The question is, how do we copy the forms? Unfortunately, Portal Forms are defined with hard-co