How to read file header/open filein binary mode

i am using FileConnenction API to read from a file. how can i open a file in binary mode so that i can read file header. In other words i want to open a file in binary mode.

You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
~

Similar Messages

  • How to read File Header in JAVA

    I wanna upload a(doc/pdf) file from client site, where I hv to check whether the the file is originally a doc/pdf file or not, I mean not just the extension, but the actual header information of the file. Please some body help me to do this, I dont know how to read the file header. Thnx in advnc.

    You can always try looking at the [Header Signatures|http://www.techpathways.com/uploads/headersig.txt]. But it would probably be easier to adjust your application so it doesn't have to guess.
    ~

  • New-line Character for a file opened in BINARY mode for O/P

    Can anybody please tell me how to put a new-line charcter for each record in a file opened in Binary mode for O/p. I cant use text mode  for other reasons in my scenario.
    DATA: l_outdata TYPE xstring.
    OPEN DATASET file FOR OUTPUT IN BINARY MODE.
    Application logic to populate l_outdata
    TRANSFER l_outdata TO file.
    Any help, or attempt towards it will be duely rewarded,
    Thanks in advance,
    Sujit.

    hi sujit,
    1. how to put a new-line charcter for each record
    but how will you decide, at which POSITION,
    to put the new line character, if u have opened the file in binary  mode.
    2. However, if u know the exact positions(s),
      u can use  CL_ABAP_CHAR_UTILITIES=>CR_LF
      to insert the new line character,
    regards,
    amit m.

  • Vc++ how to read column header of cursor

    How to fetch the Column name or header of the stored procedure which is using a cursor as the output.
    P_out  out sys_refcursor
    need to read the column name of this output.
    I am using Vc++ code to reterive the data, in Vc++ how to read column header of cursor

    You haven't provided much detail to go on.  How are you reading data from the ref cursor? Do you already have a reader from it?
    Maybe this helps.
    Greg
    create or replace procedure proc1 (v1 out sys_refcursor) as
    begin
    open v1 for select * from emp;
    end;
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class RefCur
        public static void Main()
            using (OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl"))
                con.Open();
                using (OracleCommand cmd = new OracleCommand("proc1", con))
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new OracleParameter("v1", OracleDbType.RefCursor, ParameterDirection.Output));
                    cmd.ExecuteNonQuery();
                    using (OracleDataReader reader = ((OracleRefCursor)cmd.Parameters[0].Value).GetDataReader())
                        for (int i=0;i<reader.FieldCount;i++)
                            Console.WriteLine(reader.GetName(i));

  • [Urgent] How to read files from different directories?

    I am new to Java Programming, I would like to know how to read files from directories other than the current one? (example as follows)
    ProjectDirectory
    |--MainDirectory
    |--MainProgram.java
    |--SupplementDirectory
    |--SupplementProgram.java
    |--Pictures
    |--Image.gif
    What should I write in the MainProgram.java so that I can use the supplementProgram.java from MainProgram and read the Image.gif file from the MainProgram.java?
    Thanks

    Run through the I/O tutorial here. It should get you up to speed on this sort of thing...

  • Issue in trasfering records to file using Transfer (in Binary mode)

    Hi all,
    I am using a trasfer statement to write the contents of internal table onto a file in Apllication server.
    My  code is
       LOOP AT i_file.
           TRANSFER  i_file-rec_data TO i_pf_names-v_name.
       ENDLOOP
    I am opening the file in binary mode.Its not writing the second record totally. Each of my record is 432 characters in length. Irrespective of  no. of records in my internal table its writing only 1 rec completely and half of second record.
    I am aware that opening a file in binary mode ignores the line breaks.
    So, opening in binary mode should write 1000 characters. Its writing 511 characters and stopping. Its not writing further records though my internal table is having records.
    Can you please help.

    Hi,
    If you are viewing the application server file in AL11, you wont be able to view the total length of the file even though it is written. To confirm this use the transaction CG3Y and download the application server to presentation server and check if the whole of the record is written
    Regards,
    Vikranth

  • Adobe reader X cannot open in protected mode

    I am getting the message "Adobe Reader cannot open in Protected Mode due a problem with your system configuration.
    None of the threads or other troubleshooting tips I've found have resolved this.
    Just clicking on the Adobe Reader icon by itself causes the problem. 
    Here's my process explorer output.
    Process PID CPU Private Bytes Working Set Description Company Name
    System Idle Process 0 98.46 0 K 28 K 
    System 4  0 K 236 K 
    Interrupts n/a < 0.01 0 K 0 K Hardware Interrupts and DPCs
    smss.exe 576  172 K 440 K Windows NT Session Manager Microsoft Corporation
      csrss.exe 640  1,680 K 3,652 K Client Server Runtime Process Microsoft Corporation
      winlogon.exe 664  7,948 K 8,200 K Windows NT Logon Application Microsoft Corporation
       services.exe 712  2,240 K 4,556 K Services and Controller app Microsoft Corporation
        vmacthlp.exe 892  964 K 3,248 K VMware Activation Helper VMware, Inc.
        svchost.exe 912  3,204 K 6,352 K Generic Host Process for Win32 Services Microsoft Corporation
         wmiprvse.exe 2160  4,376 K 6,028 K WMI Microsoft Corporation
         wmiprvse.exe 3392  7,644 K 6,916 K WMI Microsoft Corporation
         wmiprvse.exe 1124  2,664 K 6,116 K WMI Microsoft Corporation
        svchost.exe 1000  2,068 K 4,740 K Generic Host Process for Win32 Services Microsoft Corporation
        btservice.exe 1096  11,720 K 22,260 K BeyondTrust Shared Service BeyondTrust Software, Inc.
        MsMpEng.exe 1112  90,952 K 56,476 K Antimalware Service Executable Microsoft Corporation
        svchost.exe 1256  18,404 K 29,452 K Generic Host Process for Win32 Services Microsoft Corporation
        svchost.exe 1284  1,536 K 3,980 K Generic Host Process for Win32 Services Microsoft Corporation
        svchost.exe 1400  1,496 K 3,700 K Generic Host Process for Win32 Services Microsoft Corporation
        spoolsv.exe 1500  4,840 K 7,208 K Spooler SubSystem App Microsoft Corporation
        jqs.exe 1820  2,360 K 1,476 K Java(TM) Quick Starter Service Sun Microsystems, Inc.
        vmamqpd.exe 1892  2,500 K 5,260 K VMware AMQP Service VMware, Inc.
        vmtoolsd.exe 388  7,304 K 9,404 K VMware Tools Core Service VMware, Inc.
        vmware-update-agent.exe 460  7,880 K 12,176 K 
        CcmExec.exe 532  15,296 K 26,724 K CCM Executive Microsoft Corporation
        VMUpgradeHelper.exe 1432  1,408 K 4,896 K VMware virtual hardware upgrade helper application VMware, Inc.
        alg.exe 544  1,364 K 3,944 K Application Layer Gateway Service Microsoft Corporation
       lsass.exe 724  5,068 K 2,028 K LSA Shell (Export Version) Microsoft Corporation
    explorer.exe 3536  22,392 K 30,256 K Windows Explorer Microsoft Corporation
    VMwareTray.exe 3756  5,768 K 8,372 K VMware Tools tray application VMware, Inc.
    VMwareUser.exe 3788  7,564 K 11,000 K VMware Tools Service VMware, Inc.
    msseces.exe 3812  14,640 K 19,180 K Microsoft Security Client User Interface Microsoft Corporation
    acrotray.exe 3904  4,364 K 7,148 K AcroTray Adobe Systems Inc.
    jusched.exe 3948  3,272 K 5,604 K Java(TM) Update Scheduler Sun Microsystems, Inc.
    ctfmon.exe 3976  2,852 K 4,388 K CTF Loader Microsoft Corporation
    procexp.exe 1276 1.54 16,208 K 23,264 K Sysinternals Process Explorer Sysinternals - www.sysinternals.com
    AcroRd32.exe 1152  1,548 K 5,616 K Adobe Reader  Adobe Systems Incorporated
    Process: AcroRd32.exe Pid: 1152
    Name Description Company Name Version
    AcroRd32.exe Adobe Reader  Adobe Systems Incorporated 10.1.0.534
    advapi32.dll Advanced Windows 32 Base API Microsoft Corporation 5.1.2600.5755
    btpload32.dll BeyondTrust Profiler Loader BeyondTrust Software, Inc. 5.1.0.10
    clbcatq.dll  Microsoft Corporation 2001.12.4414.700
    comctl32.dll User Experience Controls Library Microsoft Corporation 6.0.2900.6028
    comdlg32.dll Common Dialogs DLL Microsoft Corporation 6.0.2900.5512
    comres.dll  Microsoft Corporation 2001.12.4414.700
    ctype.nls  
    gdi32.dll GDI Client DLL Microsoft Corporation 5.1.2600.5698
    imm32.dll Windows XP IMM32 API Client DLL Microsoft Corporation 5.1.2600.5512
    kernel32.dll Windows NT BASE API Client DLL Microsoft Corporation 5.1.2600.5781
    locale.nls  
    msctf.dll MSCTF Server DLL Microsoft Corporation 5.1.2600.5512
    msctfime.ime Microsoft Text Frame Work Service IME Microsoft Corporation 5.1.2600.5512
    msvcrt.dll Windows NT CRT DLL Microsoft Corporation 7.0.2600.5512
    ntdll.dll NT Layer DLL Microsoft Corporation 5.1.2600.6055
    ntmarta.dll Windows NT MARTA provider Microsoft Corporation 5.1.2600.5512
    ole32.dll Microsoft OLE for Windows Microsoft Corporation 5.1.2600.6010
    oleaut32.dll  Microsoft Corporation 5.1.2600.6058
    privman32.dll BeyondTrust PowerBroker Desktops DLL BeyondTrust Software, Inc. 5.1.0.42
    psapi.dll Process Status Helper Microsoft Corporation 5.1.2600.5512
    rpcrt4.dll Remote Procedure Call Runtime Microsoft Corporation 5.1.2600.6022
    samlib.dll SAM Library DLL Microsoft Corporation 5.1.2600.5512
    secur32.dll Security Support Provider Interface Microsoft Corporation 5.1.2600.5834
    shell32.dll Windows Shell Common Dll Microsoft Corporation 6.0.2900.6072
    shlwapi.dll Shell Light-weight Utility Library Microsoft Corporation 6.0.2900.5912
    sortkey.nls  
    sorttbls.nls  
    unicode.nls  
    user32.dll Windows XP USER API Client DLL Microsoft Corporation 5.1.2600.5512
    userenv.dll Userenv Microsoft Corporation 5.1.2600.5512
    uxtheme.dll Microsoft UxTheme Library Microsoft Corporation 6.0.2900.5512
    version.dll Version Checking and File Installation Libraries Microsoft Corporation 5.1.2600.5512
    wldap32.dll Win32 LDAP API DLL Microsoft Corporation 5.1.2600.5512

    Your log file shows you to be running v10.1.0.534. Could you please update to the latest version which is v10.1.1 and then try again. You can get it from here: http://get.adobe.com/reader/direct/
    Also, has a rule been created in the BeyondTrust Software application you appear to be using to allow Reader X to open in Protected Mode? That application might be interfering with the way Reader X operates. There's a demo on their site which might help: http://www.beyondtrust.com/Products/PowerBroker-Desktops-Windows-Edition/Product-Demo/

  • How to read the header of an FLV 1.1 file?

    I would like to read the header of an FLV file and determine
    if it's an FLV 1.1 file, and if so, get it's length. (Without
    downloading the entire file. ) How do I do this?

    bump

  • How to read,dispaly and open pdf files

    Hi, I am very new to Java butI have VB6.0 background. My current requirement is to read pdf file names from a directory, then
    show them on a form in a list (with their path in background pointing to the actual pdf files) and then once a user clicks any
    file name, open that file on the form.
    For example:
    My pdf files are in a directory as following:
    C:\myreports\user1\
    report1.pdf
    report2.pdf
    report3.pdf
    C:\myreports\user2\
    report1.pdf
    report5.pdf
    The output on the form should look like this if user1 has logged in the system. Side note: I am able to get userid of the logged in person in a variable.
    My Reports:
    . Report 1
    . Report 2
    . Report 3
    When a user clicks Report 1, it opens on the same form in pdf format.
    Thanks
    S.yhong

    For the first part (Listing thepdf files in the directory) you can use the java.lang.File class.
    File f = new File("path to your directory");
    File files[] = f.listFiles();
    then process the files array to find the files with extenction pdf
    You can also use a file filter object and make the listFiles method return only the pdf files.
    Please read the documentation about the File class for more info about it.
    */ For the displaying the pdf part is it good enough if you load the accrobat reader and with it. In that case you can do that using the Runtime.exec
    Also you can search for free java based pdf viewers I am sure there must be meny.
    And also the JTextPane might support pdf but I am not sure about it.
    EDIT:
    Just to say that this is my 1000th post :)
    Message was edited by:
    LRMK

  • How to set file to open with the latest entry?

    My "sent" file always opened at the latest entry showing the last email I'd sent but, for some unknown reason, it now loads at the top of the file showing the earliest entry. How do I get it to go back to showing the latest entries, the bottom of the file, rather than the top of the file?

    Click on the header labeled DATE to sort on that column. Click the same header a second time to reverse the sort.

  • How to read file from remote machine

    Hello,
    Hi, i would like to know how to read text file from remote machine using java source code, any code ?
    Thanks very much;
    Best regards
    Kim

    On the server, perform the following steps:
    Parse the request and determine the file to serve
    Open a FileInputStream to the appropriate file
    Obtain a reference to the Servlet OutputStream
    Pipe the bytes from the file to the output stream
    Flush and close the streamYou might want to call HttpServletResponse.setContentType("application/octet") to indicate to the browser that a file download will be occurring. Do so before getting the reference to the Servlet's OutputStream.
    - Saish

  • How to read file from server if I have a logical file path?

    Hi guys,
    I'm having a pretty "on the run" question,
    My program is currently reading a file from server using "open dataset" with file path like this (just example)
    /usr/interface/abc/bcd/testfile.dat
    Now I got a requirement to make it more consistent to read files, instead of reading that physical file name, I should read the files from a specific folder using logical path.
    So I go to T code "FILE" and created a logical path called ZABC_FILE_PATH, unix compatible, with physical path is (for example),
    /usr/interface/<sysid>/<client>/<filename>
    My question is, can I still use open dataset statement to read this? if yes, how do I do that? If no, there should be alternative way, please let me know what you think. Thanks,

    Thanks all, I figured it out.
    ONe thing is that typo double quote
    The other thing is the importing part, I need the full file path.
    CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
      EXPORTING
        CLIENT                           = SY-MANDT
        logical_path                     = 'ZABC_MY_LOGICAL_FILE_PATH'
    *   OPERATING_SYSTEM                 = SY-OPSYS
    *   PARAMETER_1                      = ' '
    *   PARAMETER_2                      = ' '
    *   PARAMETER_3                      = ' '
    *   USE_BUFFER                       = ' '
        file_name                        =  v_1
    *   USE_PRESENTATION_SERVER          = ' '
    *   ELEMINATE_BLANKS                 = 'X'
      IMPORTING
        FILE_NAME_WITH_PATH              = v_what_I_need
    * EXCEPTIONS
    *   PATH_NOT_FOUND                   = 1
    *   MISSING_PARAMETER                = 2
    *   OPERATING_SYSTEM_NOT_FOUND       = 3
    *   FILE_SYSTEM_NOT_FOUND            = 4
    *   OTHERS                           = 5
    I really appreciate your contributions, thanks again!

  • How to read files....plzzz

    Hi! All,
    I have a problem in reading files using jfilechooser class.
    when i select open menuitem from the file menu and reading it through
    the file reader class it is giving nullpointer exception.
    Also i tried by hardcoding filename in filereader class instead of using getSelectedfile().This time it is not giving null pointer exception but it is showing any stuff.
    Here's the code i am using...
    int returnVal = fc.showOpenDialog(openpanel);
    if(returnVal == JFileChooser.APPROVE_OPTION){
    file = fc.getSelectedFile();
                   //This is where a real application would open the file.
    if(fc == null)
         file = new File("D:\\karthik\\java\\");
         file = new File("D:\\karthik\\java\\kar.txt");
         fc.setCurrentDirectory(file);
    BufferedReader infile = new BufferedReader(new FileReader(file));
         files.append(infile.readline()); //files is the textarea..

    how come you do a fc.setCurrentDirectory(file);?
    where exactly do you get the NullPointerException? what does your stacktrace say?
    thomas

  • HOW to read file using ftp???

    Hi to all,
    I have problem with reading file using ftp connection, i want to read only 1024 bytes for one time, and i have
    next code wich read this:
    byte buffer[] = new byte[1024];
    while( (readCount = input.read(buffer)) > 0) {
    bos.write(buffer, 0, readCount);
    but I dont know how to put all read data in one byte[] if i dont know length of file.
    I can't do some like: byte file[] = new file[1000000];
    Thanks for all sugestions!

          * Download a file from a FTP server. A FTP URL is generated with the following syntax:
         * <code>ftp://user:password@host:port/filePath;type=i</code>.
          * @param ftpServer FTP server address (incl. optional port ':portNumber').
          * @param user Optional user name to login.
          * @param pwd Optional password for <i>user</i>.
          * @param fileName Name of file to download (with optional preceeding relative path, e.g. one/two/three.txt).
          * @param destination Destination file to save.
         * @throws MalformedURLException, IOException on error.
         public void download(String ftpServer, String user, String pwd, String fileName, File destination) throws MalformedURLException, IOException {
            if (ftpServer != null && fileName != null && destination != null) {
                StringBuffer sb = new StringBuffer("ftp://");
                if (user != null && pwd != null) { //need authentication?
                    sb.append(user);
                    sb.append(':');
                    sb.append(pwd);
                    sb.append('@');
                }//else: anonymous access
                sb.append(ftpServer);
                sb.append('/');
                sb.append(fileName);
                sb.append(";type=i"); //a=ASCII mode, i=image (binary) mode, d= file directory listing
                BufferedInputStream bis = null;
                BufferedOutputStream bos = null;
                try {
                    URL url = new URL(sb.toString());
                    URLConnection urlc = url.openConnection();
                    bis = new BufferedInputStream(urlc.getInputStream());
                    bos = new BufferedOutputStream(new FileOutputStream(destination.getName()));
                    int i;
                    while ((i = bis.read()) != -1) { //read next byte until end of stream
                        bos.write(i);
                    }//next byte
                } finally {
                    if (bis != null) try { bis.close(); } catch (IOException ioe) { /* ignore*/ }
                    if (bos != null) try { bos.close(); } catch (IOException ioe) { /* ignore*/ }
            }//else: input unavailable
        }//download()If you don't want to strore the data into a file, use ByteArrayOutputStream instead of a FileOutputStream.

  • How to read file on demand (or) avoid polling in bpel 11g?

    Hello -
    Scenario - Receive two files(A & B) which should end up in two tables (Header, Lines)
    BPEL process -
    1) Receive acitivity - To Read file (A) via File adapter
    2) Tranformed
    3) Invoked the Db adapter to insert into "Header" table
    4) Added another Receive activity - To Read file (B) via File adapter
    5) Transformed
    6) Invoked the Db adapter to insert into "Line" table
    Issue - Step 4 gets fired as a SEPARATE instance (but no data in lines table) . At the end - I see the BPEL process which is waiting for File B. Even after I dropped File B - I dont see any records going into tables.
    Is there a better way to design this process? Do I need to separate BPEL process to insert into Header & Line table? If so - how can I make this sequential process?
    Appreciate detailed steps, if possible
    Thanks
    Babu

    If its really a SyncRead Step 4 willl not run as a seperate process.
    Step1: Initiates the process once the header file arrived
    Step4: Will be invoked like a normal partnerlink.
    Just make sure, you put the lines file before the header file in the directory.
    If it doesnot resolve the problem, send your project to me helloprasanna at rediffmail.com . I'll have a look.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for