“java.net.MalformedURLException:未找到协议”读到html文件 [英] "java.net.MalformedURLException: Protocol not found" read to html file
本文介绍了“java.net.MalformedURLException:未找到协议”读到html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到了一个错误消息: java.net.MalformedURLException:找不到协议
I receviced an error: java.net.MalformedURLException: Protocol not found
我想读一个网络上的HTML文件
I want to read an HTML file on the web
mainfest ::::: uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
import com.doviz.R.id;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
public String inputLine;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
String myUri = "";
myUri = "www.tcmb.gov.tr/kurlar/today.html";
Toast.makeText( this, "step-1 " , Toast.LENGTH_LONG).show();
try{
Toast.makeText( this, "step -2" , Toast.LENGTH_LONG).show();
myUri = "www.tcmb.gov.tr/kurlar/today.html";
URL url = new URL(myUri);
Toast.makeText( this, "step-3" , Toast.LENGTH_LONG).show();
final InputStream is =url.openStream();
Toast.makeText( this, "step -4" , Toast.LENGTH_LONG).show();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
Toast.makeText( this, "step -5 " , Toast.LENGTH_LONG).show();
String line;
Toast.makeText( this, "step-6" , Toast.LENGTH_LONG).show();
while ((line=reader.readLine())!=null){
// page.add(line);
}
Toast.makeText( this, " step-7" , Toast.LENGTH_LONG).show();
}
catch(Exception e){
//e.printStackTrace();
TextView tx =(TextView)findViewById(id.TextView1);
tx.setText(myUri + " >>> "+ e.getMessage());
Toast.makeText( this, "problem = " + e.getMessage() + " -- "+ e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
//System.exit(1);
}
Toast.makeText( this, "step -8" , Toast.LENGTH_LONG).show();
}
推荐答案
您的URI不是URI。没有协议组件。它需要http://或您想要的任何其他协议。
Your URI is not a URI. There is no protocol component. It needs http:// or whatever other protocol you intend.
这篇关于“java.net.MalformedURLException:未找到协议”读到html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文