This.getclass (). getClassLoader (). GetResource ("") encountered a workaround with Chinese path

Source: Internet
Author: User

Use this.getclass (). getClassLoader (). GetResource (""). GetPath () Gets the file path of the Chinese name and inserts the binary data into MySQL, but an error occurred, the print path, Find the path is garbled, it should feel like

The problem of coding, Baidu looked under, find others to provide solutions, tested, feasible.

http://blog.csdn.net/lzzyok/article/details/7886914

In use like this:

Java code
    1. This.getclass (). getClassLoader (). GetResource (""). GetPath ()

To get the file path, the path space inside will be replaced by "%20", at this time if you use this to obtain a path containing "%20" to new file, there will be no path found error.

Then there are the following official solutions:

Java code
    1. Uri uri = new Uri (Url.tostring ());
    2. FileInputStream FIS = new FileInputStream (Uri.getpath ())

But there is another workaround:

Java code
    1. Configpath = Java.net.URLDecoder.decode (Configpath,"Utf-8");

So, the problem solved ...

This.getclass (). getClassLoader (). GetResource ("") encountered a workaround with Chinese path

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.