Filetype out of unzipped XSTRING

Hello developers!
Hope anybody of you can help me with question.
I created a report with that i generate an interactive form, zip it and send it out as attachement by miall to my customers.
Then i get from the customers the zip file back. But the zip file can content a XML or a PDF file.
So in my mial inbound process, i receive the zip file and unzip it. Then i have the XML or PDF
file in xstring format. My problem is, how can i recognize, if my xstring is XML file or a PDF file.
Does a method or class exist, where i can import the xstring and i can some document attributes back?
Regards
Barney

Hi!
When i read the content, i cannot definitly search for XML or PDF. Because when i convert
my XSTRING to STRING, i get for PDF some characterse like %PDF and for XML some characters like #X#M#L#
and i will not search in the string for such values.
So does anybody have another idea? Because it could be, that i get also .TXT or .CSV files in my zip file.

Similar Messages

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

  • Adcfgclone.pl errored out with  Unzip FAC-50409: Exiting, fatal unzip error

    Hi,
    while i am doing application cloning i got the following error message:
    Beginning application tier Apply - Thu Jul 7 17:03:07 2011
    Log file located at /u02/appl/appltest/preprod/prodappl/admin/preprod_cjb112vsa400/log/ApplyAppsTier_07071703.log
    | 66% completed Unzip Failed:
    / 66% completed AC-50409: Exiting, fatal unzip error; /u02/appl/appltest/preprod/prodcomn/clone/bin/../appl/AT_inderpdbs/stage/java0.zip failed
    ERROR while running Apply...
    ERROR: Failed to execute /u02/appl/appltest/preprod/prodcomn/clone/bin/adclone.pl
    my zip version is 2.31 and OS is RHEL 5.5 but souse OS is on RHEL3
    Please suggest how to resolve this one.

    What is the application release?
    | 66% completed Unzip Failed:
    / 66% completed AC-50409: Exiting, fatal unzip error; /u02/appl/appltest/preprod/prodcomn/clone/bin/../appl/AT_inderpdbs/stage/java0.zip failedCan you find this zip file (java0.zip)? If yes, can you unzip it manually?
    Thanks,
    Hussein

  • Display pdf of an xstring directly in ERP

    Hi,
    I am trying to generate a pdf-file out of an xstring-object which I got from the pdf creation in webdynpro.
    I want to display the pdf directly in the erp-system. Does anybody know how to convert the xstring to pdf and how to directly show the pdf without saving it to harddisk?
    Thanks in advance,
    Patrick

    Check this out -:)
    <a href="https://wiki.sdn.sap.com/wiki/display/Snippets/SAPPDFViewer">SAP PDF Viewer (Code Gallery)</a>
    Greetings,
    Blag.

  • Problem in unzipping a file : ZipInputStream

    Hi All,
    I am having some issues in unzipping a zip file using ZipInputStream.
    Following is the code :
    public class ZipInputStreamExample {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              final int BUFFER = 2048;
              try {
                   ZipInputStream zip = new ZipInputStream(new BufferedInputStream(
                             new FileInputStream(
                                       "OBU4526 - Change to mobile services pages-1.zip")));
                   ZipEntry entry;
                   System.out.println("hello world");
                   while ((entry = zip.getNextEntry()) != null) {
                        System.out.println("Unzipping: " + entry);
                        int count;
                        byte[] data = new byte[BUFFER];
                        FileOutputStream fout = new FileOutputStream(entry.getName());
                        BufferedOutputStream buf = new BufferedOutputStream(fout,
                                  data.length);
                        while ((count = zip.read(data, 0, BUFFER)) != -1) {
                             buf.write(data, 0, count);
                        buf.flush();
                        buf.close();
                   zip.close();
              } catch (FileNotFoundException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }Following is the exception which I am getting :
    hello world
    Unzipping: OBU4526 - Change to mobile services pages/css/
    java.io.FileNotFoundException: OBU4526 - Change to mobile services pages\css (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at com.example.io.ZipInputStreamExample.main(ZipInputStreamExample.java:37)Any problem with the code ? How could I solve this issue ? Do I need to create the directory structure (OBU4526 - Change to mobile services pages\css) ? Shouldn't the FileOutputStream create the structure if it isn't created. ?
    Any help would be appreciated.
    Thanks
    Siddharth

    ejp wrote:
    Delete that directory and try again.I did that and tried again. I refreshed and noticed that what is happening is that top level folder is being created but after that sub folders are not being created. It is not recognizing sub folders under the top level folders. Under the top level folder its directly making the file instead of making the folder. Following is the code snippet:
    while ((entry = zip.getNextEntry()) != null) {
                        System.out.println("Unzipping: " + entry);
                        int count;
                        new File(entry.getName()).getParentFile().mkdirs();
                        bos = new BufferedOutputStream(new FileOutputStream(entry.getName()));
                        while((count = zip.read(b, 0, BUFFER)) != -1){
                             bos.write(b, 0, count);
                   zip.closeEntry();
                   }Its also giving the following exception :
    Unzipping: OBU4526 - Change to mobile services pages/css/
    Unzipping: OBU4526 - Change to mobile services pages/css/discover-activate.css
    java.io.FileNotFoundException: OBU4526 - Change to mobile services pages\css\discover-activate.css (The system cannot find the path specified)
         at java.io.FileOutputStream.open(Native Method)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at java.io.FileOutputStream.<init>(Unknown Source)
         at com.example.io.ZipInputStreamExample.main(ZipInputStreamExample.java:41)It has created the folder "OBU4526 - Change to mobile services pages" but not "css". Instead of creating the folder css its creating the file css. Instead it should create the folder "css" also and then create the file "discover-activate.css". I don't know why its giving this exception. :(
    By this exception I suppose its asking us to create the css folder also. I am correct.
    What's the resolution of this issue.?
    Please do help me in resolving this issue. Thanks in advance.

  • Problem in unzip a file

    hai,
    Iam trying to unzip a file but its not working.
    //Unzip a file
      final int BUFFER = 2048;
      String zfname=application.getRealPath("/") + "temp/Bulk.zip"; 
           File  zf=new File(zfname);
      try {
             BufferedOutputStream dest = null;
             FileInputStream fis = new FileInputStream(zf);
             ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
             ZipEntry entry;
             while((entry = zis.getNextEntry()) != null)
                                       System.out.println("Extracting: " +entry);
                     int count;
                     byte data[] = new byte[BUFFER];
                    // write the files to the disk
                    File outFile=new File(outPath);
                    //FileOutputStream fos = new FileOutputStream(outFile);
                    FileOutputStream fos = new FileOutputStream(entry.getName());
                    dest = new BufferedOutputStream(fos, BUFFER);
                    while ((count = zis.read(data, 0, BUFFER))!= -1)
                        dest.write(data, 0, count);
                    dest.flush();
                    dest.close();
             zis.close();
          } catch(Exception e) {
             e.printStackTrace();
    Bulk.zip folder has the following files:
    Bulk/test.txt
    Bulk/fm.jsp
    I get the following exception
    java.io.FileNotFoundException: Bulk\test.txt
    (The system cannot find the path specified)
    Iam i making mistake in this line
    FileOutputStream fos = new FileOutputStream(entry.getName());
                    dest = new BufferedOutputStream(fos, BUFFER);Thanks,
    Thanuja.

    ok vijay iam so sorry for not mentioning how i rectified it. somehow i missed it. may be was bit excited when i got the result.
    anyways below code worked.
    //Unzip a file
        String zip_fname=request.getParameter("zfilename")!=null?request.getParameter("zfilename"):"";
        String fromZip=zip_fname;
        //out.println("FromZip:"+fromZip);
        File zipFname=new File(newFileName);
        String toLocation=newFilePath; //path to unzip the file
        String seperator = System.getProperty("file.separator");
        System.out.println("unzipping zip file to "+toLocation);
        try
            BufferedOutputStream dest = null;
            File zipDir = new File(toLocation);
             zipDir.mkdir();
            ZipFile zip = new ZipFile(fromZip);
            final int BUFFER = 2048;
            FileInputStream fin=new FileInputStream(fromZip);
            ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fin));
            ZipEntry entry;
            while((entry = zis.getNextEntry()) != null)
                     //System.out.println("Extracting: " +entry);
                     int count;
                     byte data[] = new byte[BUFFER];
                     String zip_Fname=entry.getName().substring(entry.getName().lastIndexOf("/")+1);
                        if(!zip_Fname.equals(""))
                            zipFiles.add(zip_Fname);
                  if(!zip_Fname.equals(""))  
                     FileOutputStream fos = new FileOutputStream(toLocation + seperator + entry.getName().substring(entry.getName().lastIndexOf("/")+1));
                     dest = new BufferedOutputStream(fos, BUFFER);
                     while ((count = zis.read(data, 0, BUFFER))!= -1)
                        dest.write(data, 0, count);
                    dest.flush();
                    dest.close();
             zis.close();
        catch (Exception ex)
            unZipResult++;
            System.out.println(ex);
        }Thanks,
    Thanuja.

  • Unzipping  zipfile with sub folders...using zlib java

    Hello,
    I am encounterig a problem while unzipping a zipfile using zlib.The zip file contaings subdirectories.so i am not able to unzip the zipfile.Since my code is able to unzip only the files which are in current directory.Please help me out to unzip the subdirectories using zlib.
    Please find my below code..for unzip the files in current directory..
    String destinationname = rootFolder.getAbsolutePath();
    byte[] buf = new byte[1024];
    ZipInputStream zipinputstream = null;
    ZipEntry zipentry;
    zipinputstream = new ZipInputStream(
    new FileInputStream(destinationname+"\\"+date+".zip"));
    zipentry = zipinputstream.getNextEntry();
    while (zipentry != null)
    //for each entry to be extracted
    String entryName = zipentry.getName();
         LoggerHtml.debug(entryName);
         int n;
         FileOutputStream fileoutputstream;
         File newFile = new File(entryName);
         String directory = newFile.getParent();
         if(directory == null)
         //break;
         fileoutputstream = new FileOutputStream(
         entryName);
         while ((n = zipinputstream.read(buf, 0, 1024)) > -1)
         fileoutputstream.write(buf, 0, n);
         fileoutputstream.close();
         zipinputstream.closeEntry();
         zipentry = zipinputstream.getNextEntry();
    Please provide me the coding..It is very urgent...

    google
    code #1
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    public class unzip
        public static void main(String args[])
            if(args.length < 1)
                System.out.println("Syntax : unzip zip-file destination-dir[optional]");
                return;
            try
                ZipFile zf = new ZipFile(args[0]);
                Enumeration zipEnum = zf.entries();
                String dir = new String(".");
                if( args.length == 2 )
                    dir = args[1].replace('\\', '/');
                if(dir.charAt(dir.length()-1) != '/')
                    dir += "/";
                while( zipEnum.hasMoreElements() )
                    ZipEntry item = (ZipEntry) zipEnum.nextElement();
                    if( item.isDirectory() ) //Directory
                        File newdir = new File( dir + item.getName() );
                        System.out.print("Creating directory "+newdir+"..");
                        newdir.mkdir();
                        System.out.println("Done!");
                    else //File
                        String newfile = dir + item.getName();
                        System.out.print("Writing "+newfile+"..");
                        InputStream is = zf.getInputStream(item);
                        FileOutputStream fos = new FileOutputStream(newfile);
                        int ch;
                        while( (ch = is.read()) != -1 )
                            fos.write(ch);
                        is.close();
                        fos.close();
                        System.out.println("Done!");
                zf.close();  
            catch(Exception e)
                System.err.println(e);
    }code #2
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.Enumeration;
    import java.util.SortedSet;
    import java.util.TreeSet;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipFile;
    * UnZip -- print or unzip a JAR or PKZIP file using java.util.zip. Command-line
    * version: extracts files.
    * @author Ian Darwin, [email protected] $Id: UnZip.java,v 1.7 2004/03/07
    *         17:40:35 ian Exp $
    public class UnZip {
      /** Constants for mode listing or mode extracting. */
      public static final int LIST = 0, EXTRACT = 1;
      /** Whether we are extracting or just printing TOC */
      protected int mode = LIST;
      /** The ZipFile that is used to read an archive */
      protected ZipFile zippy;
      /** The buffer for reading/writing the ZipFile data */
      protected byte[] b;
       * Simple main program, construct an UnZipper, process each .ZIP file from
       * argv[] through that object.
      public static void main(String[] argv) {
        UnZip u = new UnZip();
        for (int i = 0; i < argv.length; i++) {
          if ("-x".equals(argv)) {
    u.setMode(EXTRACT);
    continue;
    String candidate = argv[i];
    // System.err.println("Trying path " + candidate);
    if (candidate.endsWith(".zip") || candidate.endsWith(".jar"))
    u.unZip(candidate);
    else
    System.err.println("Not a zip file? " + candidate);
    System.err.println("All done!");
    /** Construct an UnZip object. Just allocate the buffer */
    UnZip() {
    b = new byte[8092];
    /** Set the Mode (list, extract). */
    protected void setMode(int m) {
    if (m == LIST || m == EXTRACT)
    mode = m;
    /** Cache of paths we've mkdir()ed. */
    protected SortedSet dirsMade;
    /** For a given Zip file, process each entry. */
    public void unZip(String fileName) {
    dirsMade = new TreeSet();
    try {
    zippy = new ZipFile(fileName);
    Enumeration all = zippy.entries();
    while (all.hasMoreElements()) {
    getFile((ZipEntry) all.nextElement());
    } catch (IOException err) {
    System.err.println("IO Error: " + err);
    return;
    protected boolean warnedMkDir = false;
    * Process one file from the zip, given its name. Either print the name, or
    * create the file on disk.
    protected void getFile(ZipEntry e) throws IOException {
    String zipName = e.getName();
    switch (mode) {
    case EXTRACT:
    if (zipName.startsWith("/")) {
    if (!warnedMkDir)
    System.out.println("Ignoring absolute paths");
    warnedMkDir = true;
    zipName = zipName.substring(1);
    // if a directory, just return. We mkdir for every file,
    // since some widely-used Zip creators don't put out
    // any directory entries, or put them in the wrong place.
    if (zipName.endsWith("/")) {
    return;
    // Else must be a file; open the file for output
    // Get the directory part.
    int ix = zipName.lastIndexOf('/');
    if (ix > 0) {
    String dirName = zipName.substring(0, ix);
    if (!dirsMade.contains(dirName)) {
    File d = new File(dirName);
    // If it already exists as a dir, don't do anything
    if (!(d.exists() && d.isDirectory())) {
    // Try to create the directory, warn if it fails
    System.out.println("Creating Directory: " + dirName);
    if (!d.mkdirs()) {
    System.err.println("Warning: unable to mkdir "
    + dirName);
    dirsMade.add(dirName);
    System.err.println("Creating " + zipName);
    FileOutputStream os = new FileOutputStream(zipName);
    InputStream is = zippy.getInputStream(e);
    int n = 0;
    while ((n = is.read(b)) > 0)
    os.write(b, 0, n);
    is.close();
    os.close();
    break;
    case LIST:
    // Not extracting, just list
    if (e.isDirectory()) {
    System.out.println("Directory " + zipName);
    } else {
    System.out.println("File " + zipName);
    break;
    default:
    throw new IllegalStateException("mode value (" + mode + ") bad");
    hth

  • Unzipping a gz file that's in a JMS Message

    Could anyone please help me figure out how to unzip a message from a JMS Message. I have tried all sorts of things and I just can't get it to work.
    Jeremy

    Hi I can just help you out how to extract file from
    zip format and hope it will help you out and i am
    giving you it by showing you one example.
    import java.util.*;
    import java.io.*;
    import java.text.*;
    import java.util.zip.*;
    public class sandyzip
         public static void main(String[] args)
         {     try{
                   Enumeration entries;
                   ZipFile zipFile;
                   ZipEntry entry =null;
                   byte[] buffer = new byte[10000];
                   int len;
                   InputStream in=null;
                   OutputStream zout=null;
    zipFile = new
    new ZipFile("D:\\JavaPractice\\04-04-2007data.zip");
                   System.out.println(zipFile);
                   entries = zipFile.entries();
                   System.out.println(entries);
    while(entries.hasMoreElements()) {
    ry = (ZipEntry)entries.nextElement();
                   in=zipFile.getInputStream(entry);
    zout=new BufferedOutputStream(new
    new
    FileOutputStream(""+"D:\\JavaPractice\\"+entry.getName
                   System.out.println("**************"+entry.getName()
                   System.out.println(zout);
                   while((len = in.read(buffer)) >= 0)
                   zout.write(buffer, 0, len);
                   System.out.println("Unzip done");
              catch (Exception ex) {
                   ex.printStackTrace();
    Hope it will server your purpose.
    Cheers
    Sandyand where did JMS fit into the equation?

  • Error while downloading data into excel file.

    Hi,
        I have a requirement to download data available in xstring to excel file.
    I have a RFC which has export parameter 'file_data' of type xstring. When i call RFC
    from web dynpro abap application it gives data out pout in xstring format.
    I am opening excel file using that xstring data as below
    cl_wd_runtime_services=>attach_file_to_response(
    i_filename = 'file.xls'
    i_content = ls_data_source-data_source   ***[xstring data from RFC]
    i_mime_type = 'x-excel/application'
    i_in_new_window = abap_true ).
    But excel file not coming in correct format. its  giving an error while download
    excel file
    Error is
          " the file you are trying to open , 'file[1].xls', is in a different format than
    specified by the file extension. Verify that the file is not corrupted and is from
    a trusted source before opening the file. Do you want to open the file now? "
    If i click on 'YES' button file opening but not in proper excel format. Data is coming
    in tab delimiter format in excel file.
    Please suggest any solution for this problem.
    Thanks,
    Venkat.

    Hi Thomas,
    Following is the logic implemented in RFC which is giving XSTRING as export parameter
    STEP1      create a dynamic internal table
               Create field catalog for the table   using LVC_FIELDCATALOG_MERGE
                   CALL METHOD cl_alv_table_create=>create_dynamic_table
                        EXPORTING
                           it_fieldcatalog = it_fieldcat
                         IMPORTING
                           ep_table        = dyn_table.
                  CREATE  EXCEL SHEET BY SENDING FIELD CATALOG AND DATA TAB
    STEP2 # Convert text table to xstring.
            CALL FUNCTION 'SCMS_TEXT_TO_XSTRING'
              IMPORTING
                buffer   = l_content
              TABLES
                text_tab = lt_data_tab
              EXCEPTIONS
                failed   = 1
                OTHERS   = 2.
    STEP3  *# Psss Data to Netweaver
              PERFORM pass_data_to_nw USING is_import
                                      CHANGING es_attachment_metadata.

  • Sending a file from Applet to servlet HELP me Please

    Sorry, i have the problem this is my code Applet & Servlet but it seems working asynchronously if you have some ideas please reply me i send bytes on outputstream but the inputstream of servlet receive nothing bytes but write my system.out.print on screen server:
    Applet:
    URL servletURL = new URL(codebase, "/InviaFile/servlet/Ricevi");
    HttpURLConnection urlConnection = (HttpURLConnection) servletURL.openConnection();
    urlConnection.setRequestMethod("POST");
    urlConnection.setUseCaches(false);
    urlConnection.setDoOutput(true);
    urlConnection.setDoInput(true);
    urlConnection.setAllowUserInteraction(false);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    urlConnection.setRequestProperty("Content-length", String.valueOf(100));
    urlConnection.connect();
    if(urlConnection.HTTP_BAD_REQUEST == HttpURLConnection.HTTP_BAD_REQUEST){
    /*System.out.println("Cattiva Richiesta: "+urlConnection.getContentEncoding());
    System.out.println("Tipo di metodo: "+urlConnection.getRequestMethod());
    System.out.println("Tipo di Risposta: "+urlConnection.getResponseCode());
    System.out.println("Tipo di messaggio: "+urlConnection.getResponseMessage());
    System.out.println("Tipo di contenuto: "+urlConnection.getContentType());
    System.out.println("Tipo di lunghezza contenuto: "+urlConnection.getContentLength());
    System.out.println("Tipo di doinput: "+urlConnection.getDoInput());
    System.out.println("Tipo di doouput: "+urlConnection.getDoOutput());
    System.out.println("Tipo di URL: "+urlConnection.getURL());
    System.out.println("Tipo di propriet� richiesta: "+urlConnection.getRequestProperty("Content-Type"));
    System.out.println("Entra if");
    DataOutputStream dout = new DataOutputStream(urlConnection.getOutputStream());
    InputStream is = urlConnection.getInputStream();
    if(ritornaFile("C:/Ms.tif", dout))System.out.println("Finita lettura");
    dout.close();
    urlConnection.disconnect();
    System.out.println("Fine Applet");
    }catch(Exception e) { System.err.println(e.getMessage());e.printStackTrace();}
    public boolean ritornaFile(String file, OutputStream ots)throws Exception{
    FileInputStream f = null;
    try{
    f = new FileInputStream(file);
    byte[] buf = new byte[4 * 1024];
    int byteLetti;
    while((byteLetti = f.read()) != -1){ots.writeByte(buf, 0, byteLetti);ots.flush();
    while((byteLetti = f.read()) != -1){ots.write(byteLetti);ots.flush();
    System.out.println("byteLetti= "+byteLetti);
    return true;
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    return false;
    }finally{
    if(f != null)f.close();
    Servlet:
    HttpSession ses = request.getSession(true);
    System.out.println("Passa servlet "+request.getMethod());
    System.out.println("Passa servlet "+ses.getId());
    ServletInputStream servletinputstream = request.getInputStream();
    DataInputStream dis = new DataInputStream(request.getInputStream());
    int c = dis.available();
    System.out.println("c="+c);
    //ServletOutputStream servletoutputstream
    //response.getOutputStream();
    response.setContentType("application/octet-stream");
    System.out.println("URI= "+request.getRequestURI());
    System.out.println("pathTranslated: "+request.getPathTranslated());
    System.out.println("RemoteUser: "+request.getRemoteUser());
    System.out.println("UserInRole: "+String.valueOf(request.isUserInRole("")));
    System.out.println("pathInfo: "+request.getPathInfo());
    System.out.println("Protocollo: "+request.getProtocol());
    System.out.println("RemoteAddr:"+request.getRemoteAddr());
    System.out.println("RemoteHost:"+request.getRemoteHost());
    System.out.println("SessionID:"+request.getRequestedSessionId());
    System.out.println("Schema:"+request.getScheme());
    System.out.println("SeesionValido:"+String.valueOf(request.isRequestedSessionIdValid()));
    System.out.println("FromURL:"+String.valueOf(request.isRequestedSessionIdFromURL()));
    int i = request.getContentLength();
    System.out.println("i: "+i);
    ritornaFile(servletinputstream, "C:"+File.separator+"Pluto.tif");
    System.out.println("GetMimeType= "+getServletContext().getMimeType("Ms.tif"));
    InputStream is = request.getInputStream();
    int in = is.available();
    System.out.println("Legge dallo stream in="+in);
    DataInputStream diss = new DataInputStream(servletinputstream);
    int ins = diss.read();
    System.out.println("Legge dallo stream ins="+ins);
    int disins = diss.available();
    System.out.println("Legge dallo stream disins="+disins);
    is.close();
    System.out.println("Fine Servlet");
    catch(Exception exception) {
    System.out.println("IOException occured in the Server: " + exception.getMessage());exception.printStackTrace();
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    processRequest(request, response);
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    public void ritornaFile(InputStream its, String fileDest )throws Exception{
    FileOutputStream f = null;
    try{
    f = new FileOutputStream(fileDest);
    byte[] buf = new byte[2 * 1024];
    int byteLetti;
    while((byteLetti = its.read()) != -1){
    f.write(buf, 0, byteLetti);
    f.flush();
    System.out.println("Byteletti="+byteLetti);
    }catch(Exception ex){
    System.err.println(ex.getMessage());
    }finally{
    if(f != null)f.close();

    Hi all,
    Can anyone help me.I am trying to send an audio file from a applet to servlet with HTTP method(no raw sockets), also the servlet shld be able to save the file on the server.Any suggestions welcome.USing audiostream class from javax.sound.sampled.
    The part of applet code which calls servlet is :
    URL url = new URL("http://" + host + "/" + context + "/servlet/UserUpdateWorkLogAudio?userid=" + userId.replace(' ', '+') + "&FileName=" + filename.replace(' ', '+'));
    URLConnection myConnection = url.openConnection();
    myConnection.setUseCaches(false);
    myConnection.setDoOutput(true);
    urlConnection.setRequestProperty("Content-Type", "application/octet-stream");
    myConnection.connect();
    out = new BufferedOutputStream(myConnection.getOutputStream());
    AudioSystem.write(audioInputStream, fileType,out); // IS THIS RIGHT APPROACH?
    ************************end of applet code**********************
    ************************servlet code******************************
    try
    {BufferedInputStream in = new BufferedInputStream(request.getInputStream());
    ????????What code shld i write here to get the audio file stream
    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(filename));
    *********************************************end***********************
    Thanks
    Joe.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Zipfile and zipinputstream code

    Hi!
    I need to unzip something that is in a bytearrayoutputstream. Since zipfile and zipinputstream does not receive bytearrayoutputstream I thought of creating my own but I don't know how to do that. I need someone to help me with the code. I need a code not advice please.
    All I know is that it should extend to zipfile .
    Please help

    ** a simple unZIP tool
    ** ex.  java UnZip file.zip file1   to unzip file 1 from file.zip
    **      java UnZip file.zip         to unzip file.zip
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    class UnZip {
      public static void main(String args[]) throws IOException {
        InputStream in = new BufferedInputStream(new FileInputStream(args[0]));
        ZipInputStream zin = new ZipInputStream(in);
        ZipEntry e;
        while((e=zin.getNextEntry())!= null) {
          if (args.length > 1) {
            if (e.getName().equals(args[1])) {
               unzip(zin, args[1]);
               break;
           unzip(zin, e.getName());
        zin.close();
      public static void unzip(ZipInputStream zin, String s) throws IOException {
        System.out.println("unzipping " + s);
        FileOutputStream out = new FileOutputStream(s);
        byte [] b = new byte[512];
        int len = 0;
        while ( (len=zin.read(b))!= -1 ) {
          out.write(b,0,len);
        out.close();
    Courtesy of : http://www.rgagnon.com/javadetails/java-0067.html and http://www.rgagnon.com/howto.html

  • Compressiong And Decompression

    Hi,
    I do have an issue with compression and decompression.
    I have used following program to compress and decompress a file...
    I don't have any issue in compression. But when same file is tried to
    decompress I am getting some exception
    <code>
    public class Zipper {
         public static void main(String args[]) {
         try{
              Zipper zipper = new Zipper();
              if(args.length <= 0)
                   throw new IllegalArgumentException("Please provide file name for compression");
              String compressedFileName = zipper.compress(args[0]);
              String deCompressedFileName = zipper.deCompress(compressedFileName);
    }catch(Exception e){
              e.printStackTrace();
              //e.getCause().printStackTrace();
    /*                                        INFLATER METHODS                                             */
         private String compress(String fileName)throws Exception{
              String outputName = fileName+".zipped";
              File inputFile = new File(fileName);
              File zippedFile = new File(outputName);
              //FileInputStream fips = new FileInputStream(inputFile);
              RandomAccessFile raf = new RandomAccessFile(inputFile,"r");
              //FileOutputStream fops = new FileOutputStream(zippedFile);
              RandomAccessFile rafOut = new RandomAccessFile(zippedFile,"rw");
              Deflater compresser = new Deflater(Deflater.BEST_COMPRESSION);
              byte[] buf = new byte[1000];
              byte[] out = new byte[50];
              int intialCount = 0;
              int zippedSize = 0;
              int count = 0;
              String tempString = null;
              while( (count = raf.read(buf)) != -1){
                   intialCount += count;
                   compresser.setInput(buf);
                   compresser.finish();
                   count = compresser.deflate(out);
                   zippedSize += count;
                   //tempString = new String(out);
                   //tempString.trim();
                   //fops.write(tempString.getBytes("UTF-8"));
                   rafOut.write(out);
                   compresser.reset();
              //fops.close();
              //fips.close();
              rafOut.close();
              System.out.println("Intial File Size "+intialCount);
              System.out.println("Zipped File Size "+zippedSize);
              return outputName;
         private String deCompress(String fileName)throws Exception{
              String outputName = fileName+".unzipped";
              File inputFile = new File(fileName);
              File zippedFile = new File(outputName);
              //FileInputStream fips = new FileInputStream(inputFile);
              RandomAccessFile raf = new RandomAccessFile(inputFile,"r");
              FileOutputStream fops = new FileOutputStream(zippedFile);
              Inflater deCompresser = new Inflater();
              byte[] buf = new byte[100];
              byte[] out = new byte[1000];
              int intialCount = 0;
              int unZippedSize = 0;
              int count = 0;
              String tempString = null;
              while( (count = raf.read(buf)) != -1){
                   System.out.println("Count = "+count);
                   intialCount += count;
                   deCompresser.setInput(buf);
                   count = deCompresser.inflate(out);
                   unZippedSize += count;
                   //tempString = new String(out);
                   //tempString.trim();
                   //fops.write(tempString.getBytes("UTF-8"));
                   fops.write(out);
                   deCompresser.reset();
              fops.close();
              raf.close();
              //fips.close();
              System.out.println("Intial File Size "+intialCount);
              System.out.println("UnZipped File Size "+unZippedSize);
              return outputName;
    </code>
    Exception I got is
    Intial File Size 125952
    Zipped File Size 4938
    Count = 100
    java.util.zip.DataFormatException: invalid bit length repeat
    at java.util.zip.Inflater.inflateBytes(Native Method)
    at java.util.zip.Inflater.inflate(Unknown Source)
    at java.util.zip.Inflater.inflate(Unknown Source)
    at Zipper.deCompress(Zipper.java:213)
    at Zipper.main(Zipper.java:29)

    How about some google?
    Ans try this one: http://www.tinyline.com/utils/index.html

  • MBA serious overheat

    MBA 13 inch, purchased January 2011.
    Severe overheating, kernel panic, shutdown...
    Preparing to board an international flight I put the computer to sleep by closing the lid and placing it in a sleave, then put it in my carry-on bag.
    About an hour into the flight I get the computer out and unzip the sleave, hold the computer to pull it out but it is fiery hot, too hot to hold. I slip it out onto the top of my bag and let it cool down.
    On opening the lid the computer has shut down. On starting when sufficiently cool there is a kernel panic message (below).
    Apple support say "software can cause the computer to wake, even with the lid closed" and "maybe the lid opened in the bag" (not possible in a sleave), and "it only happened once so is not a problem".
    This could have caused a fire? Anyone else experienced this?
    Also the trackpad is getting loose and unresponsive. Related problem?
    Kernel Panic report:
    Interval Since Last Panic Report:  1643869 sec
    Panics Since Last Report:          1
    Anonymous UUID:                    E1D096E8-532D-42F4-9F20-DCA9F50B4BB5
    Sun Jun 12 11:38:28 2011
    panic(cpu 0 caller 0x226b57): "thread_invoke: preemption_level -2, possible cause: unlocking an unlocked mutex or spinlock"@/SourceCache/xnu/xnu-1504.9.37/osfmk/kern/sched_prim.c:1471
    Backtrace (CPU 0), Frame : Return Address (4 potential args on stack)
    0x6c1c3e08 : 0x21b510 (0x5d9514 0x6c1c3e3c 0x223978 0x0)
    0x6c1c3e58 : 0x226b57 (0x59076c 0xfffffffe 0x590704 0x226427)
    0x6c1c3ed8 : 0x22725d (0x900d01c 0x900d01c 0x6c1c3f38 0x2329f4)
    0x6c1c3f48 : 0x2272c8 (0x275659 0x8498e0 0x0 0x6c1c3fc8)
    0x6c1c3f68 : 0x2759cf (0x275659 0x8498e0 0x0 0x1000)
    0x6c1c3fc8 : 0x2a06dc (0x8498e0 0x0 0x10 0x8de8dc4)
    BSD process name corresponding to current thread: kernel_task
    Mac OS version:
    10J869
    Kernel version:
    Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386
    System model name: MacBookAir3,2 (Mac-942C5DF58193131B)
    System uptime in nanoseconds: 126981350322327
    unloaded kexts:
    com.apple.filesystems.msdosfs          1.6.3 (addr 0x13ca000, size 0x53248) - last unloaded 124092399468690
    loaded kexts:
    com.apple.filesystems.afpfs          9.7 - last loaded 121743263950933
    com.apple.nke.asp_tcp
    etc..

    Welcome to Apple Discussions.
    For freezing, repair permission under disk utility and than repair disk from your installation disk.
    For "touchpad", resetting PRAM may help. http://support.apple.com/kb/ht1379
    Cheers.

  • XFCE4 Sound and opening JARS

    Sup, I need some help with sound.
    Sound seems to work in XFCE4 when I use root, but when I use my main, it doesn't work. I did all that goodness with gpasswd -a yourusername audio, but it didn't work.
    lspci gives me this:
    00:00.0 Host bridge: Advanced Micro Devices [AMD] RS880 Host Bridge
    00:01.0 PCI bridge: Advanced Micro Devices [AMD] RS780/RS880 PCI to PCI bridge (int gfx)
    00:04.0 PCI bridge: Advanced Micro Devices [AMD] RS780 PCI to PCI bridge (PCIE port 0)
    00:05.0 PCI bridge: Advanced Micro Devices [AMD] RS780 PCI to PCI bridge (PCIE port 1)
    00:06.0 PCI bridge: Advanced Micro Devices [AMD] RS780 PCI to PCI bridge (PCIE port 2)
    00:11.0 SATA controller: ATI Technologies Inc SB7x0/SB8x0/SB9x0 SATA Controller [IDE mode]
    00:12.0 USB Controller: ATI Technologies Inc SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
    00:12.1 USB Controller: ATI Technologies Inc SB7x0 USB OHCI1 Controller
    00:12.2 USB Controller: ATI Technologies Inc SB7x0/SB8x0/SB9x0 USB EHCI Controller
    00:13.0 USB Controller: ATI Technologies Inc SB7x0/SB8x0/SB9x0 USB OHCI0 Controller
    00:13.1 USB Controller: ATI Technologies Inc SB7x0 USB OHCI1 Controller
    00:13.2 USB Controller: ATI Technologies Inc SB7x0/SB8x0/SB9x0 USB EHCI Controller
    00:14.0 SMBus: ATI Technologies Inc SBx00 SMBus Controller (rev 3c)
    00:14.2 Audio device: ATI Technologies Inc SBx00 Azalia (Intel HDA)
    00:14.3 ISA bridge: ATI Technologies Inc SB7x0/SB8x0/SB9x0 LPC host controller
    00:14.4 PCI bridge: ATI Technologies Inc SBx00 PCI to PCI Bridge
    00:18.0 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor HyperTransport Configuration
    00:18.1 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor Address Map
    00:18.2 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor DRAM Controller
    00:18.3 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor Miscellaneous Control
    00:18.4 Host bridge: Advanced Micro Devices [AMD] Family 10h Processor Link Control
    01:05.0 VGA compatible controller: ATI Technologies Inc M860G [Mobility Radeon 4100]
    02:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8187SE Wireless LAN Controller (rev 22)
    03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8101E/RTL8102E PCI Express Fast Ethernet controller (rev 02)
    And now the other issue:
    So, I have minecraft, I can open it with java, but I wanted to install some mods, and in order to do that, I need a program for arch that opens the jar file and edit it and not spit it out like unzip does. (The mod is Optifine if you were wondering!)

    Just to clarify, you have no sound at all (besides root login) or it always starts muted?
    If the second case:
    #alsamixer
    Un-mute required channels and set default volume level
    #alsactrl -f /var/lib/alsa/asound.state store
    Save the default levels you just set.
    Finally, start alsa on boot, so the default levels you just saved are restored, by adding alsa to your daemons in rc.conf
    If the first case, check the wiki for troubleshooting info https://wiki.archlinux.org/index.php/Ad … chitecture
    Cheers.

  • Classpath is incomplete

    Hi,
    I am being faced with a problem while configuring my project in Eclipse.
    While giving a build in Eclipse its shwoing me the error of 'classpath is incomplete
    Error The project was not built since its classpath is incomplete. Cannot find the class file for org.apache.xpath.CachedXPathAPI. Fix the classpath then try rebuilding this project.
    I am not sure which jar to check in my lib folder to see whether does really the class file exist or not?.....
    please help me out people.

    unzip your jars to se where the class file is

Maybe you are looking for

  • Problem about Installation J2SDK1.3.1 on Solaris 2.6

    hi,happy new year everyone, I have installed J2SDK1_3_1_02-solsparc.sh on Solaris 2.6, and it prompted to me installation sucessfully. but when I run javac or other commands, it prompts to me the following error: *************************************

  • Coding in the Trasformation  to allow only few currency types.

    HI Can you please let me know how i can write a program which allows only few currency's to be accepted and if other then these currency exists that particular record to be deleted before loading into the PSA I wrote a code llike this but this is onl

  • HT1351 My ipod will sync with my music library but willno longer download purchased music. What can I do to correct this?

    My Ipod will not download purchased music even though it displays "synchronizing" message. This was never a problem before. Note: my ipad will not sync either. I have my music library stored in a PC Windows 7). Is there something that I am not doing

  • Multi currency reporting in Projects

    Hi, We have created a custom report for giving the overall project status. The data is captured primarily from RPSCO, QMEL, COEP, COSS and COFP tables.  Now our company is going for global rollout and include GBP currency in addition to USD. Whne I t

  • Regarding MCBA character selection.

    Hi, When I am performing transaction MCBA and selecting all the characteristics like Plant, Storage location, MAterial, Month, Valuation class, MRP controller, etc. When executing the report the output is delivered. But while downloading it via XXL t