尝试在 FileInputStream 中转换文件时出现 FileNotFound 异常

我正在尝试将 .wav 文件转换为 FileInputStream。这些 .wav 文件位于服务器上。该服务器只能通过给定的 IP 地址访问。当我在 chrome 上点击它们时,这些 .wav 文件正在成功播放。但是在转换时,java 代码给了我 FileNotFoundException。我怎么解决这个问题 ?谢谢你。


以下网址是其中之一


https:\\192.168.1.252\\monitor_wav\\OUT7048-20180503-083949-1525316989.211806.wav

以下是我转换文件的代码


   try {

        File fl = new File("https:\\192.168.1.252\\monitor_wav\\OUT7048-20180503-083949-1525316989.211806.wav");

        FileInputStream fis = new FileInputStream(fl);

    } catch (Exception e) {

        e.printStackTrace();

    }

我面临以下错误


java.io.FileNotFoundException: https:\192.168.1.252\monitor_wav\OUT7048-20180503-083949-1525316989.211806.wav (The filename, directory name, or volume label syntax is incorrect)

at java.io.FileInputStream.open0(Native Method)

at java.io.FileInputStream.open(FileInputStream.java:195)

at java.io.FileInputStream.<init>(FileInputStream.java:138)

at com.transfer.conn.Test.wavToStream(Test.java:19)

at com.transfer.conn.Test.main(Test.java:25)


子衿沉夜
浏览 334回答 2
2回答

不负相思意

试试这个try {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; URL url = new URL("https:\\192.168.1.252\\monitor_wav\\OUT7048-20180503-083949-1525316989.211806.wav");&nbsp; &nbsp; URLConnection connection = url.openConnection();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; InputStream is = connection.getInputStream();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.printStackTrace();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }

ITMISS

通常在java音频文件中处理: -try {&nbsp; &nbsp; &nbsp;File fileIn = new File(somePathName);&nbsp; &nbsp; &nbsp;AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(fileIn);}catch (Exception e) {&nbsp; &nbsp; &nbsp;e.printStackTrace();}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java