Read the content of a file (via socket)

Hi,
I need to read the content of a file (.txt, or better, .jpg) and to write it again in another file.
I have this code (in Javascript):
    conn = new Socket;
    conn.encoding = "BINARY";
    if (conn.open ("127.0.0.1:8888")) {
    conn.timeout=30;
    conn.writeln("GET variousFiles/file.jpg HTTP/1.1");
    reply = conn.read(999999);
    conn.close();
    var file = new File("C:/APPS/New_File.txt");
    file.encoding = 'BINARY';
    var open_file = file.open("w+");
    file.write(reply);
    } else { alert("Errore: " + conn2.error); }
However my new file is always empty, because I can not read the content of the first file.
My variable "reply" is always empty.
Thanks and best regards.

There is a particular case with sugested function, if content is generated on the fly by the server -php, cgi, etc.-
In this case, http server doesn´t knows total size of response data, so response shows a chunked transfer-encoding header and data is parted in chunks, each one starting with it´s size, and following the data.
HTTP/1.1 200 OK
Date: Tue, 30 Apr 2013 12:43:41 GMT
Server: Apache/1.3.31 (Win32) mod_fastcgi/2.4.1
Connection: close
Transfer-Encoding: chunked
Content-Type: image/jpeg
f49
ÿØÿà  JFIF
I´m using this function to decode parted response, with initial chunkedString with firs chunk size; in this case, f49:
PartsSeparator="\r\n";
function getPartedBody(partedBodyString) {
    var separatorPosition=partedBodyString.indexOf(PartsSeparator);
    var chunkSize=new Number("0x"+partedBodyString.substring(0,separatorPosition));
    separatorPosition+=PartsSeparator.length;
    var bodyString=new String("BINARY");
    bodyString="";
    if (chunkSize>0)
        bodyString=partedBodyString.substring(separatorPosition,separatorPosition+chunkSize)+
            getChunkedResponse(partedBodyString.substring(separatorPosition+chunkSize+PartsSeparator. length));
    return bodyString;
Hope this helps
regards

Similar Messages

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • Reading the contents of a File without using the  fileref

    Hi ,
    I was trying to read the contents of a file (not upload
    basically) without using the fileref.upload or any servlets.
    I wanted to give this file as input(dataprovider) to a
    datagrid from the local instead of uploading it to the server and
    fetching the contents from there.
    I will explain the scenerio here:
    1.I have a text field. (Here I am providing the path of the
    file located).
    2.There is a Submit button .(On click should be able to take
    the specified file as input and read the contents of the file)
    which should be able to read the contents of the file path
    specified in step1.
    I want to basically provide the contents of this xml file as
    data provider to a datagrid.
    can anyone please provide some help on this issue.
    thanks

    You cannot access the local file system in Flex. You need to
    upload the file to the server, and then populate the file from that
    uploaded file. Unless of course you are using AIR, then this is
    doable.

  • Does Acrobat Pro read the content in pdf file and transforms it?

    Does Acrobat Pro read the content in pdf file and transforms it to xls file without the need for much changes or manual work?

    Acrobat X (Standard and Pro) will save tabular data to XLS or XLSX format, provided it can recognize the table as being a table. If the PDF has missing or incorrect structure tags, Acrobat will try to guess the table layout by the position of text and lines on the page - this works well for basic formatting but if the table has complex styling, spanned cells etc. it can lead to problems.
    Acrobat X will even attempt to export a table within a scanned document, by applying OCR during the export stage - though again this relies on the table being visually identified.
    See http://www.adobe.com/products/acrobatpro/pdf-to-word-excel-converter.html and this article on how to extract one table from a larger document.

  • Read the content of a file attached to a document

    Hi,
    I have a requirement to read the content of the file attached to the document and send in the body of the email. The original get stored in the KPRO server. Can anyone suggest how can i read the content of the file stored in the KPRO server. HTTp is used to save the file in KPRO server.
    thanks
    Papiya

    Dear Papiya,
    if I got your problem correctly you are looking for some report to get the originals files from the content server and then send it via e-mail?
    In this case the report DMS_KPRO_READ may be useful for you. You can start this report in transaction SE38. You just need to enter the document data and then all attached originals will be listed with the corresponding PHIO- and LOIO-ID. Further there is also a small grenn download button to get this file on your PC.
    Best regards,
    Christoph
    P.S.: Please reward points for useful information.

  • How to read the contents of attached files

    Hi,
    I am designing a Form using LiveCycle Designer 8.0
    Scenario:
    User can attach the file through "Attachments" facility provided on Adobe  Reader.
    The requirement is to attach 3 documents and post it to SAP system using Web services.
    I am using the following code(which i got from this forum only) to find the number of files user has attached.
    d = event.target.dataObjects;
    n =  d.length;
    xfa.host.messageBox("Number  of Attachments: "+n);
    //Displaying  the names of the Attached files
    for( i =  0; i < n; i++ )
    xfa.host.messageBox("Name  of the file: "+d[i].name);
    My problem: is how to read the contents of the attached files so that I post it to SAP using Web services
    Thanks in advance!!
    Taha Ahmed

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to read the content of .msg file type with attachments in SAP crm?

    Hi All,
    Need to develop a RFC FM which will take any BP number as input
    Read the attachments in the BP and identify the attachment which is an email( .msg).
    Identify by the mime type and file extension
    Scan through the email to get the attachments of that email read the content of the
    attachment as a binary file and return that binary file with file name, size
    etc.
    I need to read the data (in binary format) attachment of an attachment of .msg file type .
    I have done till step 2 .
    Please help me on step 3.
    Thanks&Regards,
    Pratap Naik

    Can any one help me on this ?
    Thanks in advance.
    Regards,
    Pratap Naik

  • How to read the contents of redolog files?

    Hi,
    I would want to read the contents of the redolog files on my database.
    Actually, I can't because these files are binary files*. I would want to know if there is a way to read these redolog files , if for example Oracle has tools to learn these redolog files.
    Thanks.

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to read the contents of Uploaded File Data?

    Dear Experts,
    I want to develop one webdynpro application in which the iview contains the FileUpload option.and after uploading i need to read the contents of the file.
    Can you plz guide me how to achieve this?
    its very much helpfull if u have any sample project / code on this...plz do send it to [ycsvissu at gmail dot com]
    Regards,
    Viswes.

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • Reading the contents of RTF file

    Hi,
    I would like to read the contents of an RTF file which contains static text and place holders. The place holders have to be mapped to a database column(s) and once it is done I have to rewrite the output again to an RTF file. Is there any Java API directly available for this?

    Hey! Did you ever find a decent solution to this. I'm trying to do something similar.
    Read in an RTF file with some of the document already there, and embeded tags.
    These tags will be replaced with more RTF (which I would like to generate).
    Any pointers appreciated
    Regards
    Scott

  • How to read the contents of a file present in local file system

    Hi ABAP Experts,
       I want to read the file contents of a file in the local system. I want to read it stream based i.e if the file is if 100kb in size, i want to read the first 100bytes at one time, next 50 kb after, and remaining some other time. Is this possible. I know that with GUI_UPLOAD i can get the total contents into a xstring.
    But how to resolve the following i am not sure. Can you please help.
    Thanks & Regards,
    Vinay.

    Hi,
    transfer file to your application server and use:
    open dataset file ... AT POSITION p .
    regards Andreas

  • Reading the contents of a file

    hi,
    i want to read from a text file and store the contents to a String. can anyone tell me how to this plzzz. thanx a lot

    import java.io.*;
    import java.util.Scanner;
    public class ScannerTest {
        public static void main(String[] args) throws IOException {
            Scanner scanner = new Scanner(new File("ScannerTest.java"));
            scanner.useDelimiter("\\z"); //end of input
            String s = scanner.next();
            System.out.println("["+s+"]");
            scanner.close();
    }http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
    http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html#bounds
    Note that Scanner was introduced in the current version of Java.
    You may still be using an older version, like 1.4

  • I want to read the contents of a file to a text item line by line dynamical

    I have created a timer
    tm_id := FIND_TIMER('LOG_READING_TIMER');
    If Id_Null(tm_id)
    then
    tm_id := create_timer('LOG_READING_TIMER', 1000, REPEAT);
    else
    set_timer (tm_id, 1000, REPEAT);
    end if;
    /* executed the shell script on application server */
    host(v_command,no_screen);
    and used below code for reading a file in when timer expired
    DECLARE
    v_file_name := '/home/log.txt' /* log created during running shell script */
    BEGIN
    v_infile := Text_IO.Fopen(v_file_name , 'r');
    loop
    Text_IO.Get_Line(v_infile,v_linebuf);
    :CONTROL.item:= :CONTROL.item||v_linebuf||chr(10);
    end loop;           
    WHEN no_data_found THEN
         Text_IO.Fclose(v_infile);
         delete_timer('LOG_TIMER');
    END
    I want to read a log file which is created while runnning shell script line by line
    dynamically
    Above code is reading the log filebut all the lines are shown at once.
    I have to display
    each line on the text item
    and the next line line by line
    Can anyone help me how to achieve this.
    Thanks,
    in advance

    In when-button-pressed trigger
    I have called a shell script on application server using host command
    HOST('Path of script',NO_SCREEN);
    Shell script writes some set of statements to log file on application server
    Problem is to read the log file on to the multiline text item each line simultaneosly
    while running the script.
    Below is the procedure i have written to achieve this but below code is writing all the lines at once
    after entire complete execution of shell script.
    for example
    shell script writes tolog file:
    1. 'Loading of tables';
    then loads the data
    2. 'emailing data';
    3. ...
    4. ...
    Below code writes
    all the 4 lines at once
    I want to see in frontend what is going on while running the script
    by reading the log file data line by line
    WHEN-BUTTON-PRESSED
    tm_id := FIND_TIMER('LOG_READING_TIMER');
    If Id_Null(tm_id)
    then
    tm_id := create_timer('LOG_READING_TIMER', 1000, REPEAT);
    else
    set_timer (tm_id, 1000, REPEAT);
    end if;
    /* executed the shell script on application server */
    host(v_command,no_screen);
    WHEN-TIMER-EXPIRED
    and used below code for reading a file in when timer expired
    DECLARE
    v_file_name := '/home/log.txt' /* log created during running shell script */
    BEGIN
    v_infile := Text_IO.Fopen(v_file_name , 'r');
    loop
    Text_IO.Get_Line(v_infile,v_linebuf);
    :CONTROL.item:= :CONTROL.item||v_linebuf||chr(10);
    end loop;
    WHEN no_data_found THEN
    Text_IO.Fclose(v_infile);
    delete_timer('LOG_TIMER');
    END
    While running the script on application server
    I want to see the data from log file simulataneously on to the form when the data is written on to the log file
    Please let me know if you need more details.
    Thanks,
    in advance

  • Reading the contents of a file using readLine()

    Hi everyone,
    I am reading from a file using the readLine() method and assigning the value to a String. Now using readLine() i can read only a single line in the document. My file consists of several lines. how do i read from all the lines and assign it to a String? Please help.
    File f = new File("mydata.txt");
    FileInputStream fis = new FileInputStream(f);
    BufferedInputStream bis = new BufferedInputStream(fis);
    dis = new BufferedReader(new InputStreamReader(bis));
    fileText = dis.readLine();
    System.out.println(fileText);
    }Thanks

    Hi,
    Create a while loop, and continue as long as the line read != null.
    Kaj

  • How to read the contents of a file from batch file

    Hi
    I have a text file which contains exe files.  I need to read those exe file names and then execute the same in order they occur. Sample content of the text file a.txt is as below.
    "If you are looking at previous version then use 8792xINT.EXE if you are looking for the current version then check 8793xINT.exe
    please use README.TXT file before you use any above files" 
    I need to read and execute 8793xINT.exe from above text in batch file.  Here number 8793 is variable changes as version changes but xINT.exe is constant.
    Thank you in advance
    DBC
    DBC

    Sorry... 
    code i use is here -
    strScriptFile = Wscript.ScriptFullName ' C:\Patch\test_download3.vbs
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.GetFile(strScriptFile)
    strFolder = objFSO.GetParentFolderName(objFile) 
    Set objShell = CreateObject("WScript.Shell")
    strLink = "http://dbc.download.com/patches/" 
    strSaveTo = "C:\patches"
    objShell.CurrentDirectory = strSaveTo
    objShell.Run Quotes(strFolder & "\wget.exe") & " " & Quotes(strLink) & " -N",1,True
    objShell.CurrentDirectory = strFolder
    Function Quotes(strQuotes)
    Quotes = chr(34) & strQuotes & chr(34)
    End Function
    the above code geneates index.html.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
     <HEAD>
      <TITLE>Index of /140410/patches/</TITLE>
     </HEAD>
     <BODY>
    <H1>Index of /140410/patches/</H1>
    <PRE>   <A HREF="?N=D">Name</A>                              <A HREF="?M=A">Last modified</A>        <A
    HREF="?S=A">Size</A>  
    <HR>
    <IMG SRC="/icons/dir.gif" ALT="[DIR]"> <A HREF="..">Parent Directory</A>                  12-Oct-2014 16:25     1k  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="8792KB.exe">8792KB.exe</A>                      18-Oct-2014 1:19  6.4M  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="8793KB.exe">8793KB.exe</A>                      18-Oct-2014 2:19  4.2M  
    <IMG SRC="/icons/dir.gif" ALT="[FILE]"> <A HREF="2834KB.exe">2834KB.exe</A>                      20-Oct-2014 16:18  2.5M  
    <IMG SRC="/icons/dir.gif" ALT="[DIR]"> <A HREF="extra/">extra/</A>                            17-Sep-2013 23:09     1k  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="readme.txt">readme.txt</A>                        30-Jan-2012 11:54    20k  
    </PRE><HR>
    </BODY></HTML>
    From above generated index file and re run the above script to in loop to download the exe files in c:\patches and deploy the same with schedule task on the PC in our Isolated ODC. Number of exe files this time only 3 exe.  I am using counter to loop
    the down load. 

Maybe you are looking for

  • How to migrate from BE6000 to Communications Manager

    Dear forum members, first of all, I'am tired. I have been on a long journey from the day we bought our Cisco Unified Communication system until now. Technically everything worked just fine, right from the beginning until now. But starting from the fi

  • Question in invoking a bpel process from adf (how to return a table)

    hi all, i have developed a bpel process that checks customer name and if the customer name is valid , it will go to query a table of product and send this data to the client (jsf) In my bpel process ,there are two services 1. Getcustomer service--> t

  • Mail SMTP (outgoing) does not work after Yosemite upgrade

    I have just updated Yosemite on my Mac and MacBook Air and the outgoing mails cannot be sent - the SMTP-connection fails. It worked fully Ok few seconds before the upgrade was started. So, I wonder if anyone or Apple can help on getting the Outgoing

  • Windows 10 Home Insider Preview crashed my hp pavilion g7

    I downloaded the Windows 10 Home Insider Preview build 103310 and it crashed my computer. Have me the error code 0xc000000f. What can i do?

  • How do i make websites think my mobile is a desktop?

    How do i make websites think my mobile is a desktop? I cant stand those sites where it forces you to view the "mobile version" i want Firefox to automatically tell them its a "desktop" not a "mobile" so that i can go to any site without changing anyt