0

i am trying to convert .wav files to FileInputStream. These .wav files are located on the server. This sever is accessible only by given IP address. these .wav files are successfully playing when i hit them on chrome. But at the conversion time the java code is giving me FileNotFoundException. how can I solve this problem ? thank you.

following URL is one of them

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

following is my code to convert file

   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();
    }

i am facing the following error

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)
InsaneCat
  • 2,115
  • 5
  • 21
  • 40
Ashwini Pandey
  • 115
  • 2
  • 2
  • 9
  • 4
    Possible duplicate of [Download file from HTTPS server using Java](https://stackoverflow.com/questions/10135074/download-file-from-https-server-using-java) – Arnaud Aug 06 '18 at 12:02
  • i am not downloading files. I am converting them. – Ashwini Pandey Aug 06 '18 at 12:12
  • 4
    `FileInputStream` is for files in a local file system, not files on a remote server accessed via http(s). Hence accessing a file via http(s) is downloading. – Robert Aug 06 '18 at 12:21
  • 2
    `File` does not support HTTP/HTTPS... in order to do this, you either need to download the file to a local storage then convert it, or do it on the fly while downloading, in all cases you need a code to download the file, example, you can use `Apache Commons IO` library as in this answer https://stackoverflow.com/a/4698213/3604083 – Yazan Aug 06 '18 at 12:24
  • i got it :-) i need to first download – Ashwini Pandey Aug 07 '18 at 05:15

2 Answers2

0

try this


try {
                URL url = new URL("https:\\192.168.1.252\\monitor_wav\\OUT7048-20180503-083949-1525316989.211806.wav");
    URLConnection connection = url.openConnection();
                InputStream is = connection.getInputStream();
            } catch (Exception e) {
                e.printStackTrace();
            }
Vaibhav Singh
  • 177
  • 10
-2

normally in java audio files are handled by:-

try {
     File fileIn = new File(somePathName);
     AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(fileIn);
}catch (Exception e) {
     e.printStackTrace();
}
azro
  • 53,056
  • 7
  • 34
  • 70