How To: Get encoding of a remote file

How To: Get encoding of a remote file
Java EE
URL url = new URL ("http://www.someSite.com/myCsvFile.csv"); // comma separated
InputStream is = url.openConnection().getInputStream();
InputStreamReader reader = new InputStreamReader(is);
System.out.println("reader.getEncoding(): " + reader.getEncoding());
For both an ISO-8859-1 file and a UTF-8 file I get the following print out:
reader.getEncoding(): Cp1252
Could it have something to do with this warning during boot the .war?
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
If I use local files it prints ISO8859_1 for one of the files.

All of that is because the HTTP server attaches a charset to every response. That's what you are seeing. The server may be using some logic to determine the actual encoding of the file it returns, or it may simply be using a hard-coded charset which may or may not be suitable for reading the file. The latter is unfortunately more likely.
By the way if you receive an XML file over HTTP, and the HTTP charset differs from the encoding declared in the XML document, there's a rule which says the HTTP charset takes precedence. (I don't know where that rule is documented, but I have encountered that situation in real life -- the data came from a Google application -- and that rule was indeed the right thing to do.)
If you're still under the impression that there's something which can look at a file and determine what encoding was used to produce it, let me tell you that there isn't. Sure, there's that XML prolog thing which works for XML files (if they weren't botched by the producer), but for text files in general there's no way to determine their encoding. Short of asking the person who created them, that is.

Similar Messages

  • How to get Header in Downloaded .xls file using  GUI_Download function

    How to get Header in Downloaded .xls file using  GUI_Download function ???
    How to use the the Header parameter available in GUI_Download function .

    HI,
    see this sample code..
    data : Begin of t_header occurs 0,
           name(30) type c,
           end of t_header.
    data : Begin of itab occurs 0,
           fld1 type char10,
           fld2 type char10,
           fld3 type char10,
           end   of itab.
    DATA: v_pass_path TYPE string.
    append itab.
    itab-fld1 = 'Hi'.
    itab-fld2 = 'hello'.
    itab-fld3 = 'welcome'.
    append itab.
    append itab.
    append itab.
    append itab.
    append itab.
    t_header-name = 'Field1'.
    append t_header.
    t_header-name = 'Field2'.
    append t_header.
    t_header-name = 'Field3'.
    append t_header.
      CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
        EXPORTING
          default_extension     = 'XLS'
        IMPORTING
          fullpath              = v_pass_path.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = v_pass_path
          filetype                        = 'DBF'
        TABLES
          data_tab                        = itab
          FIELDNAMES                      = t_header
    Cheers,
    jose.

  • How to get field separator in flat file using GUI_DOWNLOAD function

    hi,
    how to get field separator in flat file using GUI_DOWNLOAD function.
                                    thanking you.

    Hi,
      Use WRITE_FIELD_SEPARATOR = 'X'.
      Check this sample code
    REPORT  z_file_download.
    DATA: w_name(90) TYPE c.
    DATA:
      BEGIN OF fs_flight,
        carrid   LIKE sflight-carrid,
        connid   LIKE sflight-connid,
        fldate   LIKE sflight-fldate,
        price    LIKE sflight-price,
        currency LIKE sflight-currency,
      END OF fs_flight.
    DATA:
      BEGIN OF fs_head,
        carrid(10) TYPE c,
        connid(10) TYPE c,
        fldate(10) TYPE c,
        price(10) TYPE c,
        curr(10) TYPE c,
      END OF fs_head.
    DATA:
      t_head LIKE
       TABLE OF
             fs_head.
    DATA:
      t_flight LIKE
         TABLE OF
               fs_flight.
    fs_head-carrid = 'CARRID'.
    fs_head-connid = 'CONNID'.
    fs_head-fldate = 'FLDATE'.
    fs_head-price  = 'PRICE'.
    fs_head-curr   = 'CURRENCY'.
    APPEND fs_head TO t_head.
    SELECT-OPTIONS:
      s_carrid FOR fs_flight-carrid.
    START-OF-SELECTION.
      SELECT carrid
             connid
             fldate
             price
             currency
        FROM sflight
        INTO TABLE t_flight
       WHERE carrid IN s_carrid.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
    *   BIN_FILESIZE                  =
        filename                      = 'D:\flight.xls'
       FILETYPE                      = 'ASC'
    *   APPEND                        = ' '
        WRITE_FIELD_SEPARATOR         = 'X'
    *   HEADER                        = '00'
    *   TRUNC_TRAILING_BLANKS         = ' '
    *   WRITE_LF                      = 'X'
    *   COL_SELECT                    = ' '
    *   COL_SELECT_MASK               = ' '
    *   DAT_MODE                      = ' '
    *   CONFIRM_OVERWRITE             = ' '
    *   NO_AUTH_CHECK                 = ' '
    *   CODEPAGE                      = ' '
    *   IGNORE_CERR                   = ABAP_TRUE
    *   REPLACEMENT                   = '#'
    *   WRITE_BOM                     = ' '
    * IMPORTING
    *   FILELENGTH                    =
      tables
        data_tab                      = t_head
    EXCEPTIONS
       FILE_WRITE_ERROR              = 1
       NO_BATCH                      = 2
       GUI_REFUSE_FILETRANSFER       = 3
       INVALID_TYPE                  = 4
       NO_AUTHORITY                  = 5
       UNKNOWN_ERROR                 = 6
       HEADER_NOT_ALLOWED            = 7
       SEPARATOR_NOT_ALLOWED         = 8
       FILESIZE_NOT_ALLOWED          = 9
       HEADER_TOO_LONG               = 10
       DP_ERROR_CREATE               = 11
       DP_ERROR_SEND                 = 12
       DP_ERROR_WRITE                = 13
       UNKNOWN_DP_ERROR              = 14
       ACCESS_DENIED                 = 15
       DP_OUT_OF_MEMORY              = 16
       DISK_FULL                     = 17
       DP_TIMEOUT                    = 18
       FILE_NOT_FOUND                = 19
       DATAPROVIDER_EXCEPTION        = 20
       CONTROL_FLUSH_ERROR           = 21
       OTHERS                        = 22
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'D:\flight.xls'
          filetype                = 'ASC'
          append                  = 'X'
          write_field_separator   = 'X'
        TABLES
          data_tab                = t_flight
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 6
          header_not_allowed      = 7
          separator_not_allowed   = 8
          filesize_not_allowed    = 9
          header_too_long         = 10
          dp_error_create         = 11
          dp_error_send           = 12
          dp_error_write          = 13
          unknown_dp_error        = 14
          access_denied           = 15
          dp_out_of_memory        = 16
          disk_full               = 17
          dp_timeout              = 18
          file_not_found          = 19
          dataprovider_exception  = 20
          control_flush_error     = 21
          OTHERS                  = 22.
      IF sy-subrc EQ 0.
        MESSAGE 'Download successful' TYPE 'I'.
      ENDIF.
      IF sy-subrc <> 0.
    *  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

  • How 2 get the path of a file

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • How 2 get the path of a file Using jsp

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • How to get instrument and plug in files to logic8?

    How to get instrument and plug in files to logic8?
    I lost mine in a hard drive crash.
    I cant use my DVD jam pack
    This is my spec
      Modellnamn:          iMac
      Modellidentifierare:          iMac8,1
      Processornamn:          Intel Core 2 Duo
      Processorhastighet:          2,4 GHz
      Antal processorer:          1
      Totalt antal kärnor:          2
      L2-cache:          6 MB
      Minne:          3 GB
      Busshastighet:          1,07 GHz
      Boot ROM-version:          IM81.00C1.B00
      SMC-version (system):          1.29f1
    iMac, OS X Mountain Lion (10.8.2)

    I think you want to get the latitude and longitude information of client accessing the web application. In the web application you cannot directly get the client location information as the nature of the web application is different from windows applications.
    I advise you to develop a Silverlight component and in that Silverlight component use geolocation classes to get client location. Please refer this article for getting data in Silverlight http://www.c-sharpcorner.com/UploadFile/82b980/getting-geo-location-of-user-in-silverlight/
    And once you get the location information you can send that data back to ASP.net webpage or call any javascript method as shown here http://ovaismehboob.wordpress.com/2013/06/22/bridging-data-between-asp-net-and-silverlight/
    Hope this helps!
    Ovais Mehboob Ahmed Khan http://ovaismehboob.wordpress.com

  • How to get endtime of a redolog file

    How to get endtime of a redolog file..
    i get start time from the following statement..but the high time shows as
    01-JAN-1988 00:00:00
    select TO_CHAR(LOW_TIME,'DD-MON-YYYY HH24:MI:SS'),TO_CHAR(HIGH_TIME,'DD-MON-YYYY HH24:MI:SS') from v$logmnr_logs;
    where do i get the correct end time

    i need the high time of the current redo log..using the folowing query i get
    select min(to_char(first_time, 'DD-MON-YY HH24:MI')),
    max(to_char(first_time, 'DD-MON-YY HH24:MI')),MEMBERS from v$log
    group by members;
    MIN(TO_CHAR(FIR MAX(TO_CHAR(FIR MEMBERS
    28-NOV-07 09:33 28-NOV-07 12:19 1
    it returns the max and min low time among all redo logfiles
    what I need is the high time of current log file.
    using the next query i get
    select min(TO_CHAR(LOW_TIME,'DD-MON-YYYY HH24:MI:SS')),max(TO_CHAR(LOW_TIME,'DD-MON-YYYY HH24:MI:SS')) from v$logmnr_logs;
    28-NOV-2007 12:19:09 28-NOV-2007 12:19:09
    since i add only current log file to log mining session, v$logmnr_logs would only have information about that file(one row only). so will get same time here for min and max. What i need here is high_time of the current redo log file.
    Any idea?

  • How to get hostname of a remote computer by ip

    how to get hostname of a remote computer by ip

    In InetAddress class we have a method
    public String getHostName() which returns the name of the host. If applet security prevents the name, the same ipaddress entered is returned back.
    This program is the implementation of this method:
    import java.net.*;
    public class ipdemo
    public static void main(String arg[])
    try
    InetAddress add=InetAddress.getByName("207.228.236.39");
    System.out.println(add.getHostName());
    catch(UnknownHostException e)
    System.out.println("Exception raised");
    This will help you.
    Regards.
    Deepa Datar

  • How can get a database like ****.SQL file for test in sqlplus in oracle8i

    How can get a database like ****.SQL file for test in sqlplus in oracle8i,I am a beginner,thanks

    I'll give it a guess as to what it is you want but I'm afraid you'll have to give some more information to go on. I appreciate it's difficult for people who are beginners or who don't have English as their first language.
    Are you trying to run a SQL file? From SQL*plus you can do either of these:
    SQL> start my_file
    or
    SQL> @my_file
    N.B.: if th efile has a .sql extension you don't need to include it, but you do for any other file extension e.g.
    SQL> @myfile.run
    Here is the page Vijay referred to:
    Re: Physical storage Checks & adding disk on server. I hope you find it useful.
    You will more helpful links (including links to the Oracle on-line manuals at this page:
    Re: How to attach a java bean in forms6i
    good luck, APC

  • How to get VQE-C SDK .tgz file

    hi, out company plans to integrate VQE-C in IPTV STB, so how to get VQE-C SDK .tgz file?
    Thx, Jerry

    any feedback pls :)

  • How i get some informations about audio file?

    Hi to all,
    i would like to know how i get some informations about audio file, such as its artist, bitrate, file type, duration, ecc...
    Any help me?

    Ok, but which are the docs of audio format?Again, what does that have to do with Java?
    Where i can found these documents?Again, what does that have to do with Java?
    Thank you...For nothing.
    db

  • How to get the complete abap help file

    hi
    how to get the complete abap help file i mean F1 file.
    please provide some me links to download that file.

    Hi Kiran,
       If u want complete help for particular topic ; for that SAP has provided in built Transaction for help.
    Transaction is ABAPDOCU.
    I have certain link which will help u.
    SAP, ABAP interview question and answers
    http://www.geocities.com/sap_interviewquestions/
    IMP Link for All
    http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm
    Common Links
    http://www.sappoint.com/abap.html
    http://www.sap-img.com/abap-function.htm
    http://www.easymarketplace.de/online-pdfs-q-s.php
    http://help.sap.com/
    http://sapassist.com/groups/groups.asp?v=sap-r3-dev&m=3&y=2004
    http://training.saptechies.com/sap-basis-certification-sample-questions/
    http://www.geocities.com/mpioud/Abap_programs.html
    http://cma.zdnet.com/book/abap/index.htm
    http://www.sapdevelopment.co.uk/
    http://www.sap-img.com/
    http://juliet.stfx.ca/people/fac/infosys/abap.htm
    http://help.sap.com
    http://www.sap-img.com
    http://www.thespot4sap.com
    http://www.sap-basis-abap.com/
    http://www.sapdevelopment.co.uk/
    http://www.sap-img.com/
    http://juliet.stfx.ca/people/fac/infosys/abap.htm
    http://help.sap.com/saphelp_46c/helpdata/en/d3/2e974d35c511d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_46c/helpdata/en/d6/0db357494511d182b70000e829fbfe/frameset.htm
    http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
    http://www.sapgenie.com/abap/example_code.htm
    http://www.geocities.com/SiliconValley/Campus/6345/abapindx.htm
    http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
    http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
    http://www.sap-img.com/abap-function.htm
    http://www.sapgenie.com/abap/code/abap19.htm
    http://www.sap-img.com/abap/more-than-100-abap-interview-faqs.htm
    http://www.planetsap.com/Tips_and_Tricks.htm
    http://help.sap.com/saphelp_40b/helpdata/ru/d6/0dc169494511d182b70000e829fbfe/applet.htm
    http://www.henrikfrank.dk/abapexamples/SapScript/symbols.htm
    http://www.henrikfrank.dk/abapexamples/index.html
    http://sap.ittoolbox.com/documents/document.asp?i=752
    http://members.aol.com/_ht_a/skarkada/sap/
    http://sappoint.com/abap/
    http://members.tripod.com/abap4/SAP_Functions.html
    http://members.ozemail.com.au/~anmari/sap/index.html
    http://www.planetsap.com/Userexit_List.htm
    http://www.planetsap.com/Tips_and_Tricks.htm
    http://www.kabai.com/abaps/q.htm
    http://www.planetsap.com/Userexit_List.htm
    http://help.sap.com/saphelp_bw21c/helpdata/en/c4/3a8090505211d189550000e829fbbd/frameset.htm
    http://www.sapgenie.com/abap/bapi/example.htm
    http://help.sap.com/saphelp_45b/helpdata/en/65/897415dc4ad111950d0060b03c6b76/content.htm
    http://www.sap-basis-abap.com/index.htm
    http://help.sap.com/saphelp_40b/helpdata/en/fc/eb2c46358411d1829f0000e829fbfe/frameset.htm
    http://help.sap.com/saphelp_46c/helpdata/en/aa/aeb23789e95378e10000009b38f8cf/frameset.htm
    http://www.geocities.com/ResearchTriangle/1635/system.html
    http://www.sapdesignguild.org/resources/MiniSG/3_Managing/3_Functions_Table_Control.htm
    http://help.sap.com/saphelp_45b/helpdata/en/d1/801bdf454211d189710000e8322d00/content.htm
    http://www.sapfans.com/sapfans/repos/saprep.htm
    http://www.planetsap.com/howdo_a.htm
    http://help.sap.com/saphelp_util464/helpdata/en/69/c2516e4ba111d189750000e8322d00/content.htm
    http://www.sapgenie.com/abap/smartforms_detail.htm
    http://www.sap-img.com/abap.htm
    http://help.sap.com/saphelp_46c/helpdata/en/fc/eb2d67358411d1829f0000e829fbfe/content.htm
    http://www.geocities.com/victorav15/sapr3/abap.html
    http://www.henrikfrank.dk/abapexamples/SapScript/sapscript.htm
    http://abap4.tripod.com/Other_Useful_Tips.html
    http://help.sap.com/saphelp_45b/helpdata/en/cf/21ee2b446011d189700000e8322d00/content.htm
    http://www.sap-basis-abap.com/sapmm.htm
    http://sap.ittoolbox.com/nav/t.asp?t=303&p=448&h1=303&h2=322&h3=448
    http://sapfans.com/
    http://cma.zdnet.com/book/abap/ch03/ch03.htm
    http://help.sap.com/saphelp_40b/helpdata/en/4f/991f82446d11d189700000e8322d00/applet.htm
    http://sappoint.com/abap/
    http://www.henrikfrank.dk/abapuk.html
    http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/abapindx.htm
    http://www.sapgenie.com/abap/index.htm
    http://www.sap-img.com/abap.htm
    http://www.sapdevelopment.co.uk/tips/tipshome.htm
    http://help.sap.com/printdocu/core/Print46c/en/Data/Index_en.htm
    http://sap.ittoolbox.com/nav/t.asp?t=322&p=322&h1=322
    http://sap.ittoolbox.com/nav/t.asp?t=448&p=448&h1=448
    http://www.thespot4sap.com/
    http://www.kabai.com/abaps/q.htm
    http://www.geocities.com/mpioud/Abap_programs.html
    http://www.sapgenie.com/abap/tips_and_tricks.htm
    http://www.sapassist.com/code/d.asp?whichpage=1&pagesize=10&i=10&a=c&o=&t=&q=&qt=
    Mark Helpfull answrs
    Regards
    Manoj

  • How to get selected sequence in a file

    Hello,
        I can get the selected sequence file by accessing the RunState.InitialiSelection.SelectedFile property. However, if i want to get the name of the sequence that was selected in this sequence file, then how can i get that?
    Thanks,
    Regards,
    Aparna

    Hello,
       Sorry, i saw this thread a little late. My question is still the same. The solution that you gave actually gives me the display name of the sequence file. But i wanted the name of the sequence that was opened withtin the sequence file. Here is what i have.
    A sequence file named TestExport.seq has two sequences  - MainSequence and SecondSequence. I open up the sequence file and open the SecondSequence in that file. But i dont know how to get this information about the sequence that is selected within the file. I have an external dll, in which i am passing the sequence file name as RunState.InitialSelection.SelectedFile. But i do not know how to get the sequence name that was actually opened in that file. Because i actually want to get the sequence context of the sequence within the file. The code that i have looks like this:
    public ExportDlg(SequenceFile seqFile)
                InitializeComponent();
                SequenceContext seqContext = seqFile.NewEditContext();
                engine = seqContext.Engine;
                object outParam = System.Type.Missing;
                this.seqContext = engine.NewEditContext(seqFile.GetSequence(0).AsPropertyObject(),System.Type.Missing,out outParam);
    seqFile.GetSequence(0) - gives me the context of the first sequence which is MainSequence. But if i have opened the SecondSequence, i need the context for that. And to get this, i need the sequence name "SecondSequence" somehow.
    RunState.InitialState.SelectedSequences is an array of containers. Although i can see the sequence name during executing, i do not know how to get the name of the container my external dll .
    Please help,
    Thanks,
    Regards,
    Aparna

  • How to get data of tabulated text file into internal table

    hi all,
    i want to get data from tabulated text file(notepad) into internal table. i searched in SCN and got lot of post regarding  how to convert excel file into internal table but i didnt get posts regarding text file.
    thanks
    SAchin

    try:
    DATA: BEGIN OF tabulator,
            x(1) TYPE x VALUE '09',
          END OF tabulator.
      READ DATASET file INTO wa.
    split wa at tabulator into table itab.
    A.

  • How to get the filename from J2SE File adapter

    In our project scenario , we are using J2EE and J2SE engine both .J2EE for mapping  and J2SE for Deliveying the message .
    In one senario, routing will be based on the filename .
    J2SE Sender File adapter --- XI Adapter --- XI pipe line
    So the File reaching to XI pipelane via J2SE File adapter--> XI adapter.
    When we are using the dynamic configurator in the XI to get the filename
    we are not able to get the file name  becasue it is coming to XI via
    XI adapter.
    How to get the filename ????Hope I am clear about the problem.

    hi,
    try this
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //obtengo la Key del FileName
    DynamicConfigurationKey keyF = DynamicConfigurationKey.getName();
    http://help.sap.com/javadocs/NW04/current/pi/com/sap/aii/mapping/api/DynamicConfigurationKey.html
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/70c89607-e4d9-2910-7280-f6746e964516
    /people/mohammed.zabiulla/blog/2008/03/26/have-you-ever-tried-to-determine-mail-cc-dynamically
    Hope it helps
    Thanks
    Rodrigo
    Edited by: Rodrigo Pertierra on Apr 11, 2008 9:31 AM

Maybe you are looking for

  • From 6i to 10g - ORA_FFI and Crystal Report experience

    Hi, we are plannig to migrate from 6i to Forms 10g. As a report tool we use Crystal Reports. Have you some experience with using this report tool in Forms 10g? Thank you

  • Error in RWB Component Monitoring ... "Domain ???"

    Hello Everyone! A problem suddenly popped up in our SLD. When I navigate to RWB > Component Monitoring... I can no longer click on the "Integration Server" The Domain shows <i>"Domain ???"</i> would anyone know what could be the problem? Warm regards

  • Want user to enter a date

    I am using Oracle 9i. I want the user to be able to enter a date and the report runs using values that are after this user inputted date, but am unsure how to do this. I have already created a user parameter that created a drop down list for the user

  • Error for font in awt from Adobe Code?

    hi, whenever i start my gui of a text editor i am getting this error code on Debian/Linux with J2SDK 1.4.2. any hints?? java: ../../../src/share/native/sun/awt/font/t2k/t1.c:2171: tsi_T1GetGlyphIndexFromAdobeCode: Assertion `0' failed. Aborted

  • Diagnostics Agent Installation in MCOD enabled systems

    Hi Experts, We are connecting MCOD anabled managed systems to Solution Mamager 7.1 SPS10. But little confused with Dagnostics agent strategy; whether Agent-On-the-fly feature can be used in this case or not? I am following SAP Note 1365123 - Installa