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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • ip addr命令详解_linux带内ip

    ip addr命令详解_linux带内ipipaddr内容解释[root@w~]#ipaddr1:lo:<LOOPBACK,UP,LOWER_UP>mtu65536qdiscnoqueuestateUNKNOWNgroupdefaultqlen1000link/loopback00:00:00:00:00:00brd00:00:00:00:00:00inet127.0.0.1/8scopehostlovalid_lftforeverpreferr

    2022年7月27日
    4
  • html背景图片如何自动平铺,html怎么设置背景图片全屏平铺?

    html背景图片如何自动平铺,html怎么设置背景图片全屏平铺?html怎么设置背景图片全屏平铺?1、新建一个html文档。2、设置一下HTML的框架,然后把图片设置在同一个文件夹里面。3、加入,这样可以有样式设置。4、因为背景设置在主体,所以还要定义为body{}。5、background-image:url(图片),这个是添加图片的意思。6、然后我们需要加入background-repeat:repeat-x;这个时候就会横向平铺。7、background…

    2022年5月15日
    66
  • pycharm崩溃_pubg lite手机闪退报错

    pycharm崩溃_pubg lite手机闪退报错问题描述今天在用pycharm跑模型时,突然报错自OutofMemoryThereisnotenoughmemorytoperformtherequestedoperation.Pleaseincrease‘Xmx’settingandrestarttheIDEforchangetotakeeffect.解决方案找到pycharm安装目录bin下的pycharm64.exe.vmoptions,用记事本打开将前两个适当加大找到bin目录下的P

    2022年8月26日
    6
  • power by dedecms什么意思,power by dedecms怎么去掉

    power by dedecms什么意思,power by dedecms怎么去掉powerbydedecms什么意思,powerbydedecms怎么去掉powerbydedecms什么意思,powerbydedecms怎么去掉一、powerbydedecms什么意思网上冲浪的时候,会看到很多带powerbydedecms的网站,powerbydedecms表示该网站基于DedeCMS系统搭建,DedeCMS是开源免费

    2022年7月13日
    15
  • Linux netstat 命令安装

    Linux netstat 命令安装当服务器未安装 netstat 工具时 查看端口监听状态会提示如下报错 commandnotfo root VM 0 15 linux netstat an grep9200 bash netstat commandnotfo 如果要使用 netstat 命令 需要先安装工具 安装步骤如下所示 一 首先配置好本机的 yum 源 root VM 0 15 linux yumrepolista faste

    2025年10月31日
    3
  • asp.net类似于js中的setTimeOut()的函数作用?

    asp.net类似于js中的setTimeOut()的函数作用?

    2021年11月17日
    45

发表回复

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

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