fileinputstream java,使用url的Java fileinputstream

fileinputstream java,使用url的Java fileinputstreamHowtoinputinthefileinputstream,afiletourl?IentertheurlintheFileinputstream,buttheoutputoftheURLiswrong,becausethelinkslashesareturnedbackwardslike-from/to\andthe…

大家好,又见面了,我是你们的朋友全栈君。

fileinputstream java,使用url的Java fileinputstream

How to input in the fileinputstream, a file to url?

I enter the url in the Fileinputstream, but the output of the URL is wrong, because the link slashes are turned backwards like – from / to \ and the double slashes // are \ only one slash and backwards.Is there a way with the fileinputstream to do that ? If it isn’t, can you tell me what should I use instead of fileinputstream?

解决方案

If you want to obtain an InputStream to retrieve data from a URL, then using the URL.openStream method will return an InputStream, which can be used like any other InputStream.

For example,

InputStream is;

// if we were getting data from a file, we might use:

is = new FileInputStream(“/path/to/file”);

// or, from a URL, then retrieve an InputStream from a URL

is = new URL(“http://google.com/”).openStream();

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/137883.html原文链接:https://javaforall.net

(0)
上一篇 2022年5月6日 上午9:05
下一篇 2022年5月6日 上午9:05


相关推荐

  • vue iframe高度自适应 实用

    vue iframe高度自适应 实用iframe 是 vue 的 在使用过程中高度根据数据实时变化 不好设置 iframe 的高度值 试了多种方式之后 总结了几种自适应的方式 实时刷新 iframe 高度变化 variframes document getElementsB iframe setInterval function for vari 0 j iframes length i

    2025年9月1日
    4
  • centos7卸载软件命令_linux安装docker

    centos7卸载软件命令_linux安装docker1首先搜索已经安装的docker安装包[root@localhost~]#yumlistinstalled|grepdocker或者使用该命令[root@localhost~]#rpm-qa|grepdockerdocker.x86_642:1.12.6-16.el7.centos@extras

    2022年8月30日
    8
  • linux 系统进行make menuconfig的时候出错

    linux 系统进行make menuconfig的时候出错错误信息:(ps:当前系统:Linuxlabpc4.13.0-36-generic#40~16.04.1-UbuntuSMPFriFeb1623:25:58UTC2018x86_64x86_64x86_64GNU/Linux)HOSTCCscripts/kconfig/mconf.oInfileincludedfromscripts/kc…

    2022年5月25日
    36
  • mysql wal_什么是 WAL

    mysql wal_什么是 WAL什么是 WALWAL WriteAheadLo 预写日志 是数据库系统中常见的一种手段 用于保证数据操作的原子性和持久性 在计算机科学中 预写式日志 Write aheadlogging 缩写 WAL 是关系数据库系统中用于提供原子性和持久性 ACID 属性中的两个 的一系列技术 在使用 WAL 的系统中 所有的修改在提交之前都要先写入 log 文件中 log 文件中通常包括 redo

    2026年3月18日
    2
  • [学习笔记]笛卡尔树[通俗易懂]

    [学习笔记]笛卡尔树[通俗易懂][学习笔记]笛卡尔树

    2022年4月21日
    41
  • 如何免费下载付费音乐歌曲,6个网站+8个APP

    如何免费下载付费音乐歌曲,6个网站+8个APP现在听音乐的软件,QQ音乐,酷狗,网易云等,很多歌曲可以在线听。但是下载某些歌曲或者在线听高品质无损的都需要付费。这一期,给大家推荐的是免费下载付费歌曲工具,包括网站跟APP。网站篇1.VIP

    2022年7月1日
    71

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号