开发者

Naming a file by a url

I am generating images of webpages from urls and writing them to my local filesystem, and I want to name the image by its url. However, if I do this, since there are /'s in the开发者_如何学JAVA url, it will create new directories instead of calling the image by the entire url. Is there a way to avoid this?


I don't believe it's possible to place a / or \ in a file name. The best thing I can think to recommend is replacing all / or \ with alternate characters not normally found in URLs, such as $ ^ , !. If you can't find a single character to replace the slash, you can use a short string that's unlikely to be in the URL, such as [slash] or a combination of symbols.

The problem to watch out for when using the short string is the length of the file names. Although most OSes won't have a problem, you may not be able to zip them with their full name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜