这段代码有什么问题,它给出了错误 [英] what is wrong with this code it gives error
本文介绍了这段代码有什么问题,它给出了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我这段代码有什么问题,它返回语法错误的错误.任何人都可以修复它吗?
can anyone tell me that what is wrong with this code it returns the error of syntax error. can anyone fix it ?
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data; name="uploaded_file";filename=""
+ fileName + """ + lineEnd);'
它的第二部分在 catch 它返回错误.请检查这个:
and its second part at catch it returns error. check this one please:
runOnUiThread(new Runnable() {
public void run() {
String msg = "File Upload Completed.
See uploaded file here :
"
+http://www.androidexample.com/media/uploads/"
+uploadFileName;
messageText.setText(msg);
Toast.makeText(UploadToServer.this, "File Upload Complete.",Toast.LENGTH_SHORT).show();
}
});
}
fileInputStream.close();
dos.flush();
dos.close();
} catch (MalformedURLException ex) {
dialog.dismiss();
ex.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
messageText.setText("MalformedURLException Exception : check script url.");
Toast.makeText(UploadToServer.this, "MalformedURLException",Toast.LENGTH_SHORT).show();
}
});
Log.e("Upload file to server", "error: " + ex.getMessage(), ex);
} catch (Exception e) {
dialog.dismiss();
e.printStackTrace();
runOnUiThread(new Runnable() {
public void run() {
messageText.setText("Got Exception : see logcat ");
Toast.makeText(UploadToServer.this, "Got Exception : see logcat ",Toast.LENGTH_SHORT).show();
}});
Log.e("Upload file to server Exception", "Exception : " + e.getMessage(), e);
}
dialog.dismiss();
return serverResponseCode;
} // End else block
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.upload_to_server, menu);
return true;
}
}
推荐答案
dos.writeBytes("Content-Disposition: form-data; name="uploaded_file";"filename=""+ fileName + """ + lineEnd);
双引号内不使用双引号,需要加上"(反斜杠)
double qoutes are not used within double qoutes, you need to put "" (backslash)
这篇关于这段代码有什么问题,它给出了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文