For Java Remote File Reading, the file address contains spaces. % Percent indicates a null pointer.

Source: Internet
Author: User

Inputstream instream = NULL;

// Connect to the specified network resource and obtain the network input stream. Conversion is required here. Otherwise, an error of NULL pointer will be reported in getinputstream () below.

 
Ftpurl = ftpurl. replaceall ("%", "% 25"); // convert the % contained in the address to % 25 ftpurl = ftpurl. replaceall ("", "% 20"); // convert the space to % 20url u = new URL (ftpurl); con = u. openconnection (); system. setproperty ("sun.net. client. defaultconnecttimeout "," 60000 "); // change jdk1.4 to this value, and the connection times out. system. setproperty ("sun.net. client. defaultreadtimeout "," 60000 "); // replace jdk1.4 with this, and the read operation times out. Con. connect (); instream = con. getinputstream ();

However, the content can be read in this way, but this address with a percent sign is still a problem when the front-end shows that the link is opened, in IE6, you can click to download, but in a high-version browser, you may not be able to download it.

I don't know any good solutions ..

This article from the link: http://www.zhqhlbt.com /? P = 238 | blog of little Z

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.