Reading Contents of URL with Spaces in its Path (+other odd characters)

Hi, I am looking for a way to get the contents of a webpage that has a pathname with odd characters in it. Here is my "contents reader":
    public static String getURLContents(URL u){
        try {
            Scanner scan = new Scanner((InputStream)u.getContent());
            String output = "";
            while (scan.hasNextLine()) {
                output += scan.nextLine()+"\n";
            return output;
        } catch (Exception ex) {
            System.out.println(ex);
            return null;
    }I have here selected exception output from two tests on the same URL, which has spaces. First, nicely formatted spaces (" "->%20)
java.io.FileNotFoundException: http://www.publichealthalert.org/articles/tinagarcia/jemsek%20part%201.htm
and Secondly, raw spaces:
java.io.IOException: Server returned HTTP response code: 400 for URL: http://www.publichealthalert.org/articles/tinagarcia/jemsek part 1.htm
The second example is obvious - there's spaces, and that's not the right way of doing things. But what's going on in the first example??
Thank you kindly,
K
Edited by: nixxlmai on Jun 8, 2009 11:56 AM

nixxlmai wrote:
java.io.FileNotFoundException: http://www.publichealthalert.org/articles/tinagarcia/jemsek%20part%201.htm
But what's going on in the first example??Do you insinuate that it works when there aren't any spaces in the URL? Have you actually tested an URL without any spaces?
This exception merely means that the URL itsn't reachable on the given domain. It's actually a 404 error.

Similar Messages

  • URLs with spaces

    I know that's a contradiction in terms but here is my problem. My database contains large numbers of 'URLs' with spaces in them reflecting where the corresponding files actually are in the file system. In the longer term I can get them converted to use %20 but in the meantime I have the problem that h:outputLink translates the spaces into +. I'm just wondering if there's something in JSF that will turn them into %20 for me? ... other than fn:replace() which I guess is not a bad alternative ...
    Thanks in advance.

    SharePoint is a Document Management system which is designed to be user-friendly. Naming all documents in your site farm with no spaces makes the document titles difficult to read for the end users. I agree that, programatically, no spaces is good, but unfortunately,
    systems are used by human beings. So even though your suggestion has been marked as an answer, it's not really a solution is it?
    The solution I came up with that solved my instance of this problem was to add a text column to the List I was working with, then put some JavaScript in the NewForm.aspx file that copies the file name into the text file and the applies an "encodeURI" to
    convert the word spaces into %20 ...
    So when I create a new item in my list, the JavaScript takes the file name, converts the spaces to %20, then copies the string into the text field in the list. When I build the WorkFlow Email, instead of concating the file name into a URL, I use the text
    field that pulls out (for example) "my%20file" and adds the pre-amble (http://myserver/path/) and the suffix (.pdf) and I have a working URL ...
    The full solution is posted at
    my blog ...

  • How to read multiple arguments separated with space in one line

    How to modify the
    public static void main (String[] args){
    }so that it can read multiple arguments separated with space in a single line?
    e.g.
    java myprogram username password host
    java myprogram2 ipaddress port
    Thx.

    public static void main (String[] args){
      int index = 0;
      for(String arg : args) {
        System.out.println("args["+(index++)+" = "+arg);
    }

  • Unable to access files with spaces in the path

    Hi all, I am accessing files which reside on the server using a java applet.
    The typical path of a file could be:
    http://192.168.0.2/agat/data/AF190701 0003.agt
    (not the space in the filename).
    When I try to open this file using a URL object:
    URL file = new URL(filename);
    BufferedReader in = new BufferedReader(new InputStreamReader(file.openStream()));
    I get exception 400 ( I think) whihc I assume is file cant be found.
    However when I rename the file (to get rid of that space) and also change the filename variable to suit. The file is opened as expected.
    What should I do to make the applet able to open paths with spaces? Or is this just not possible.
    I did try including quotes with the special characte precessor:
    filename = "/"http://192.168.0.2/agat/data/AF190701 0003.agt/""
    But this didnt work either, please could someone tell what I need.
    Thanks.

    Thanks guys, although before I got your replies I did the following - it seems to work, but shall try your suggestions.
    while (file.lastIndexOf(" ") >0)
    String temp;
    int num = file.lastIndexOf(" ");
    temp = file.substring(0, num) + "%20" + file.substring(num+1, file.length());
    file = temp;
    }

  • Bug: can't access static files with space in the path

    Please let me know if this a a wrong place to file bug reports.
    I installed webserver7u4 and when I try to access a static file within my war which contains a space in the path, I get HTTP404.
    $ ls webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black\ spinner/1.png
    webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black spinner/1.png
    $ wget -O /dev/null "http://localhost:8080/images/ddtree/black spinner/1.png
    "--13:47:06-- http://localhost:8080/images/ddtree/black%20spinner/1.png
    => `/dev/null'
    Resolving localhost... 127.0.0.1, ::1
    Connecting to localhost|127.0.0.1|:8080... connected.
    HTTP request sent, awaiting response... 404 Not found
    13:47:06 ERROR 404: Not found.Now, if I create a symlink to a path that contains url encoded space, everything works:
    $ ls -l webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black%20spinner
    lrwxrwxrwx 1 root root 13 Aug 1 2008 webserver7/https-myapp/web-app/myapp/_default/images/ddtree/black%20spinner -> black spinner
    $ wget -O /dev/null "http://localhost:8080/images/ddtree/black spinner/1.png"
    --13:49:37-- http://localhost:8080/images/ddtree/black%20spinner/1.png
    => `/dev/null'
    Resolving localhost... 127.0.0.1, ::1
    Connecting to localhost|127.0.0.1|:8080... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 1,446 (1.4K) [image/png]
    100%[======================================================================== =======================================>] 1,446 --.--K/s
    13:49:37 (89.76 MB/s) - `/dev/null' saved [1446/1446]So to me it appears that webserver doesn't decode the path before searching the local file system, which to me looks like a bug.
    Let me know if you need more info.
    cheers,
    Igor

    HTTP/1.1 RFC [http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2|http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.2]
    3.2 Uniform Resource Identifiers
    URIs have been known by many names: WWW addresses, Universal Document Identifiers,
    Universal Resource Identifiers [3], and finally the combination of
    Uniform Resource Locators (URL) [4] and Names (URN)  ... where
    3 is a link to [http://www.ietf.org/rfc/rfc1630.txt|http://www.ietf.org/rfc/rfc1630.txt] section BNF for specific URL schemes
      httpaddress              h t t p :   / / hostport [  / path ] [ ?search ]
      path                   void |  segment  [  / path ]
      segment                xpalphas
      xpalphas               xpalpha [ xpalphas ]
      xpalpha                xalpha | +
      xalpha                 alpha | digit | safe | extra | escape
      alpha                  a | b | c | d | e | f | g | h | i | j | k |
                             l | m | n | o  | p | q | r | s | t | u | v |
                             w | x | y | z | A | B | C  | D | E | F | G |
                             H | I | J | K | L | M | N | O | P |  Q | R |
                             S | T | U | V | W | X | Y | Z
      digit                  0 |1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
      safe                   $ | - | _ | @ | . | &  | + | -
      extra                  ! | * |  " |  ' | ( | )  | ,
      escape                 % hex hex
      hex                    digit | a | b | c | d | e | f | A | B | C | D | E | F{code}
    4 is a link to RFC 1738 Uniform Resource Locators (URL)
    [http://www.ietf.org/rfc/rfc1738.txt|http://www.ietf.org/rfc/rfc1738.txt] section 5. BNF for specific URL schemes
    has :
    {code}
    httpurl        = "http://" hostport [ "/" hpath [ "?" search ]]
    hpath          = hsegment *[ "/" hsegment ]
    hsegment       = *[ uchar | ";" | ":" | "@" | "&" | "=" ]
    uchar          = unreserved | escape
    escape         = "%" hex hex
    hex            = digit | "A" | "B" | "C" | "D" | "E" | "F" |
                                 "a" | "b" | "c" | "d" | "e" | "f"
    unreserved     = alpha | digit | safe | extra
    alpha          = lowalpha | hialpha
    lowalpha       = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" |
                     "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" |
                     "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" |
                     "y" | "z"
    hialpha        = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" |
                     "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" |
                     "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
    digit          = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |"8" | "9"
    safe           = "$" | "-" | "_" | "." | "+"
    extra          = "!" | "*" | "'" | "(" | ")" | ","
    {code}
    I do not see space in these RFCs for httpurl.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Encode the URL with space

    Hi all
    Ihave some content which needs to be encode with the URL..
    E.G:
    URL is --http://localhost:8080/appname/notify?
    content need to encode---msgtxt=bal P0045IN
    I am using HttpConnector.executeGetMethod(URL_BAL, URLParameters);
    But it giving Error called Sattus 505 error means http version not supported.
    What i find till now is its not allowing "SPACE"
    So please gives some idea
    thanks

    Thanks for reply
    My apllication is like this i have some values which needs to append with the URL and Hit another application which will take care furthere.
    i am using org.apache.commons.httpclient.util.EncodingUtil to encode.
    when i debug it gives right URL but not Hits the that application giving Http version not supported.
    if i copy that URL and paste it In IE ,its working bur from my application not working
    I tried with %20 also, but it giving 404 error
    Please respond

  • Programmatic launch of reader 11.0.3 won't open file with spaces in the path?

    The application I work on uses a PDF file for online help.  We programmatically launch the help file into the user's PDF viewer.  The path to the help file may have spaces in the directory names or filename.  With previous versions of Adobe Reader, it would launch just fine (path passed in on the command line).  However, with 11.0.3, I find that if I don't include an extra set of quotation marks around the path, it fails to open when there are spaces in the directory name.  What changed between then and now to cause this problem?  If I add extra quotation marks, will users with an older version of Reader not be able to open the file?
    Edit -- running in Windows 7, launched from C# .NET 3.5.

    benten2000 wrote:
    Install is fine and the icon is shown on the desktop and pdf files icons also change to Acrobat.
    I seem to have missed this part when reading your original post.  See if anything in this article fixes your problem: http://helpx.adobe.com/acrobat/kb/application-file-icons-change-acrobat.html

  • Export of schema with space it its name

    we have a schema named "Gestion Loaners" (note the space in schema name) in oracle 9iR2 database. i want to take schema level export but as there is space in schema name i am not able to do it using either escape char or using parameter file..
    can anyone guide me pls
    thx

    It works if the Username is ALL CAPITALS. Couldn't get it work if the Username was Mixed Case
    SQL> create user "PAVAN KUMAR" identified by pavan;
    User created.
    SQL> grant create session, create table to "PAVAN KUMAR";
    Grant succeeded.
    SQL> create table "PAVAN KUMAR".his_table (col_1 varchar2(5));
    create table "PAVAN KUMAR".his_table (col_1 varchar2(5))
    ERROR at line 1:
    ORA-01950: no privileges on tablespace 'USERS'
    SQL> alter user "PAVAN KUMAR" quota unlimited on USERS;
    User altered.
    SQL> create table "PAVAN KUMAR".his_table (col_1 varchar2(5));
    Table created.
    SQL>
    ora10204>exp hemant/hemant owner=\"PAVAN KUMAR\"
    Export: Release 10.2.0.4.0 - Production on Wed Nov 5 22:33:47 2008
    Copyright (c) 1982, 2007, Oracle.  All rights reserved.
    Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export done in US7ASCII character set and AL16UTF16 NCHAR character set
    server uses WE8ISO8859P1 character set (possible charset conversion)
    About to export specified users ...
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user PAVAN KUMAR
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user PAVAN KUMAR
    About to export PAVAN KUMAR's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export PAVAN KUMAR's tables via Conventional Path ...
    . . exporting table                      HIS_TABLE          0 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
    ora10204>

  • N8 - CONTACT : Unable to read content of NOTE with...

    I had highlighted this issue to Nokia many times from the time I had 5800 and now N8. In CONTACT, it is showing details of information in sync from Microsoft Outlook 2010 but when comes to NOTE, it does not display the complete detail at all. When I select NOTE tab, it will immediately go to edit mode and then this will create an error to which you can accidently delete the content written in NOTE.
    Can anyone inform how to overcome this issue or someone at Nokia Software Development take notice of this please !
    Thank you

    Hi and Welcome to the Forums!
    Anytime random strange behavior or sluggishness creeps in, the first thing to do is a battery pop reboot. With power ON, remove the back cover and pull out the battery. Wait about a minute then replace the battery and cover. Power up and wait patiently through the long reboot -- ~5 minutes. See if things have returned to good operation. Like all computing devices, BB's suffer from memory leaks and such...with a hard reboot being the best cure.
    Best!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Issue with OracleHelp loading HelpSet with space in file path

    Hi,
    I'm running into an issue where I cannot get OracleHelp to load a HelpSet correctly with RoboHelp contains when the file is in a directory with a file space in it.
    This will load successfully if the path does not contain any white spaces. It looks like oraclehelp may be running into an issue decoding the %20. Any thoughts?
    java.io.FileNotFoundException: C:\temp\qa_relea%20se\windows\data\help\oracl
    e_help_files\HelpTOC.xml (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at oracle.help.engine.DataEngine._getBufferedReader(Unknown Source)
    at oracle.help.engine.XMLTOCEngine.createDataObject(Unknown Source)
    at oracle.help.common.View.getViewData(Unknown Source)
    at oracle.help.common.navigator.tocNavigator.TOCUtils.getTopicTree(Unkno
    wn Source)
    at oracle.help.common.navigator.tocNavigator.MergingTopicTreeNode._creat
    eTopicTreeNodes(Unknown Source)
    at oracle.help.common.navigator.tocNavigator.MergingTopicTreeNode._reall
    yAddView(Unknown Source)
    at oracle.help.common.navigator.tocNavigator.MergingTopicTreeNode.addVie
    w(Unknown Source)
    at oracle.help.navigator.tocNavigator.TOCNavigator.addView(Unknown Sourc
    e)
    at oracle.help.Help._createNavigatorForView(Unknown Source)
    at oracle.help.Help._createNavigatorsForBook(Unknown Source)
    at oracle.help.Help.addBook(Unknown Source)

    Hi Experts,
    My concern was Say I delete the requests from the day the data was loaded with thw wrong update rule, I have the data sitting in the PSA and I can reconstruct them. I understand that the data can be corrected in ODS.
    But in the cube, some key figures are there with the update method as 'addition'. So say I delete the content of the cube and reload it from the ODS all over again, wont the key figures get corruipted yet again?
    Also as I was thinking, say we delete the respective request from the cube as well, and reconstruct the data in the ODS. can I fire the delta request again to capture the changed records to be loaded to cube. to be exact will all the data from the date of the data corruption(as I am going to delete the requests from the cube from that day also) will be loaded to the cube?
    Also another thing is will it be a better idea to reconstruct a request in the ODS and run the delta package for the cube.. And go on ..
    Kindly suggest..
    Thanks in advance !!!

  • Process.start("winword", filename) can not open file with space in the path and name

    Hi,
    I am trying to write a class which can open file with selected application. for simplicity, now I just hard code the varaibles.
    the problem: if the path or file name has space in it, even it exist, winword still can not open it.
    could someone kindly show me what I did wrong and how to do it properly.
    Thanks in advance.
    Belinda
    public static class FileOpen
    public static void info()
    string path = @"c:\a temp folder\aaa 1.txt";
    if (File.Exists(path))
        // the file I am using in the sample does exist
         MsgBox.info("yes");
    else
         MsgBox.info("no");
    // working
    //Process.Start("winword", "c:\\aaa.txt");
    // not working
    //Process.Start("winword", "c:\aaa.txt");
    // not working
    Process.Start("winword", "c:\\a temp folder\\aaa 1.txt");
    // not working
    Process.Start("winword", path);

    string AppPath;
    AppPath = ReadRegistry(Registry.CurrentUser, "Software\\FabricStudio", "TARGETDIR", value).ToString() + @"help";
    string FileName = "'"+ AppPath + "\\ImageSamples.doc" + "'";
    try
    System.Diagnostics.Process.Start("Winword.exe", FileName);
    can any body please help for this.
    where i am making mistake?

  • Problems with spaces in Library Paths - JDEV 9.0.4.0

    We recently moved from JDev 9.0.3 on NT to JDEV 9.0.4 on XP.
    None of the projects we had previously will run in OC4J under the new version of JDeveloper. The problem appears to be the class paths of the library files, some of the root project folders have spaces in them and JDev doesn't appear to like it.
    our file structure is like this
    D:\Dev\My Workspace\MyProject\src
    D:\Dev\My Workspace\MyProject\classes
    etc.. with the root package under source. All no brainer stuff.
    The error reported in the logging window looks like this
    Source Workspace\\MyProject\\classes;D:\\Dev\\My does not exist.
    Now if I change "My Workspace" to "MyWorkspace" in the library path the app runs fine.
    Can anyone tell me why the space is causing a problem when it never has before?

    Seems like the JDEV 9.04 Classpath format is set to not include any spaces in it.

  • Open a form with space on the path with form builder from a batch

    Hi,
    I cannot open a form from a batch on Windows if the absolute path contains spaces.
    For example, if I try to open a form in "C:\" from cmd with C:\ORANT\bin\ifbld60.exe C:\Form.fmb, I have no problem, if I try to open a form in "C:\Documents and Settings" with C:\ORANT\bin\ifbld60.exe "C:\Documents and Settings\Form.fmb" or C:\ORANT\bin\ifbld60.exe C:\Documents and Settings\Form.fmb, I have some dialog with info and the error FRM-90927 and form builder doesn't start.
    Thank you,
    tom
    Edited by: 912104 on 16-ago-2012 3.17 - title

    Hi,
    >
    I cannot open a form from a batch on Windows if the absolute path contains spaces.
    For example, if I try to open a form in "C:\" from cmd with C:\ORANT\bin\ifbld60.exe C:\Form.fmb, I have no problem, if I try to open a form in "C:\Documents and Settings" with C:\ORANT\bin\ifbld60.exe "C:\Documents and Settings\Form.fmb" or C:\ORANT\bin\ifbld60.exe C:\Documents and Settings\Form.fmb, I have some dialog with info and the error FRM-90927 and form builder doesn't start.
    >
    Why is that you want to open a FMB in Form Builder with a Batch file?
    Is it that your application has only one FMB and that you work with only one FMB all the time?
    Cheers,
    PS: And if you must open the FMB through a batch file then look up the Form Builder Help for "Command Line options". It is an excellent resource.
    Edited by: Prabodh on Aug 16, 2012 3:06 PM

  • XletApplication Manager - How to run Xlet, with spaces in the path

    Hi
    I am trying to use J9 implementation on PocketPC to run a simple Xlet. When I enter a path as below, the Xlet App manager fails to find the application.
    37#"\SD Card\IBM PPRO10\bin\j9.exe" -jcl:ppro10 com.ibm.oti.xlet.XletApplicationManager -filename:"\SD Card\ANSPOD\bin\PODXlet.txt"
    However, if I use a path that doesnt have any space, it works fine.
    Any hints ?

    Have you tried enclosing the entire shortcut in quotes?
    37#"\SD Card\IBM PPRO10\bin\j9.exe -jcl:ppro10 com.ibm.oti.xlet.XletApplicationManager -filename: \SD Card\ANSPOD\bin\PODXlet.txt"
    Or, if that doesn't work, maybe using a %20 in place of the space in the folder.
    Or, maybe this:
    37#"\'SD Card'\'IBM PPRO10'\bin\j9.exe" -jcl:ppro10 com.ibm.oti.xlet.XletApplicationManager -filename:"\'SD Card'\ANSPOD\bin\PODXlet.txt"

  • Jar and classpath with space in folder name?

    Hi, all.
    Just for fun: what if I have a jar file that is dependant on the other jar file which is placed in folder with space in its name? How would I link it in manifest file?
    Thanks.

    Havae you tried quoting the Class-Path value?

Maybe you are looking for

  • Read only access issue after time machine migrate

    Having a small issues on my new rMBP. I recently switched from my MBA to this newer rMBP and I previously had a Time Machine backup that I migrated over. For some reason though..when accessing my external hard drive it keeps asking to authenticate th

  • REG: Usage of PGP(pretty good privacy) encryption

    Hi all,              I need to use PGP encryption in XI. Can u suggest is it possible or not. If yes can you tell me how can it be done.

  • Can't access a specific site to update

    I really hope someone can help me with this. I am trying to update a website that my company manages, but for some reason, my computer is the only one that cannot access this website. Whenever I try, I get "could not be found" or "connection was refu

  • First Imac - RAM question

    Hi Ive just bought my first ever Imac, its on its way at the mo, and meanwhile Ive bought 2Gb of RAM to install myself - am I safe to install the RAM as soon as I get the Imac - before having switched it on and set it up? Also I opted for the wireles

  • My Ipad Air turns off on its own all the time. Why?

    My Ipad Air turns off on its own all the time. Why?