Android: how to parse URL String with spaces to URI object?

前端 未结 5 1486
孤城傲影
孤城傲影 2020-11-27 03:52

I have a string representing an URL containing spaces and want to convert it to an URI object. If I simply try to create it via

String myString = \"http://my         


        
5条回答
  •  醉梦人生
    2020-11-27 03:56

    URL url = Test.class.getResource(args[0]);  // reading demo file path from                                                   
                                                // same location where class                                    
    File input=null;
    try {
        input = new File(url.toURI());
    } catch (URISyntaxException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    

提交回复
热议问题