In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Linux shows that the file can not be found abnormal how to solve? In view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
Scene:
The project accesses normally under windows, but the linux throws an exception and the file cannot be found.
Analysis:
If the project file accessed is like this: abc/bcd/aa.jpg, and the path to the access file in the system is: abc/Bcd/aa.jpg, the difference between the two is that the secondary directory bcd is written as Bcd.
If you develop under windows, you can't find the error. The windows file name is case-insensitive, so you can still access the file according to abc/Bcd/aa.jpg, but the linux file directory is case-sensitive, so you can't find the file.
Solution:
In normal programming, you must write strictly.
It should also be noted that the linux directory separator is /, and under windows is\, so sometimes the file path stored in windows to the database will not be applicable to linux. It needs to be processed in the system. After the path is removed from the database, it needs to be processed as follows:
/ * modify the path, replace\\ or / with File.separator * @ param path path to be modified * @ return modified path * / public static String path (String path) {String p = StringUtils.replace (path, "\", "/"); p = StringUtils.join (StringUtils.split (p, "/"), "/") If (! StringUtils.startsWithAny (p, "/") & & StringUtils.startsWithAny (path, "\\", "/")) {p + = "/";} if (! StringUtils.endsWithAny (p, "/") & & StringUtils.endsWithAny (path, "\", "/")) {p = p + "/" } if (path! = null & & path.startsWith ("/")) {p = "/" + p; / / path under linux} return p } this is the answer to the problem of how to solve the problem when the linux display cannot find a file exception. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.