简体   繁体   English

检查服务器上是否存在音频文件

[英]Check if audio file exists on server

How can I check if audio file exists on the server? 如何检查服务器上是否存在音频文件?

I want to check if file exists on the server and play it, otherwise want to exit from the onclick event. 我想检查服务器上是否存在文件并播放它,否则要退出onclick事件。

Something like this will do: 这样的事情会做:

URL url = new URL("http://youraudiourl");
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
int responseCode = huc.getResponseCode();
if( responseCode == 200){
    // your audio file exists
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM