当我尝试发送字符串错误时显示为:
引起:java.lang.NullPointerException:尝试调用虚方法' void java.io.OutputStream.write(byte [])'在空对象引用上
(BaseApp)this.getApplicationContext()).my.BTconnect();
((BaseApp)this.getApplicationContext()).my.beginStart();
String s = "w";
try {
outputStream.write(s.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
答案 0 :(得分:0)
您应该初始化输出流。
String file_stream = "C:\Users\s.rodic\eclipse\test.txt";
String s = "w";
try {
OutputStream outputStream = new FileOutputStream(file_stream); //file_stream is your file location
outputStream.out(s.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
答案 1 :(得分:0)
我认为您的问题在写http或https,如果您希望与您的服务器连接,请尝试只写:http
String login_url = "http:`stack.com`
希望能帮到你!