什么是错的这个code提示错误 [英] what is wrong with this code it gives error
本文介绍了什么是错的这个code提示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我,什么是错的这个code返回语法错误的错误。任何人都可以修复它?
dos.writeBytes(twoHyphens +边界+ lineEnd);
dos.writeBytes(内容处置:表格数据;名称=uploaded_file;文件名=
+文件名++ lineEnd);
和在追赶它的第二部分则返回错误。检查这一项,请:
runOnUiThread(新的Runnable(){
公共无效的run(){
弦乐味精=文件上传已完成\ñ\ñ看到这里上传的文件:\ñ\ N
+ HTTP://www.androidexample.com/media/uploads/
+ uploadFileName;
messageText.setText(MSG);
Toast.makeText(UploadToServer.this,文件上传完成。,Toast.LENGTH_SHORT).show();
}
});
}
fileInputStream.close();
dos.flush();
dos.close();
}赶上(MalformedURLException的前){
dialog.dismiss();
ex.printStackTrace();
runOnUiThread(新的Runnable(){
公共无效的run(){
messageText.setText(MalformedURLException的例外情况:检查脚本的网址。);
Toast.makeText(UploadToServer.thisMalformedURLException的,Toast.LENGTH_SHORT).show();
}
});
Log.e(上传文件到服务器,错误:+ ex.getMessage(),前);
}赶上(例外五){
dialog.dismiss();
e.printStackTrace();
runOnUiThread(新的Runnable(){
公共无效的run(){
messageText.setText(GOT例外:看logcat的);
Toast.makeText(UploadToServer.this,得到了异常:看到的logcat,Toast.LENGTH_SHORT).show();
}});
Log.e(上传文件到服务器异常,异常:+ e.getMessage(),E);
}
dialog.dismiss();
返回serverResponse code;
} //结束else块
}
}
@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
。getMenuInflater()膨胀(R.menu.upload_to_server,菜单);
返回true;
}
}
解决方案
dos.writeBytes(内容处置:表格数据;名称= \uploaded_file \; \文件名= \+文件名+\+ lineEnd);
双qoutes没有双qoutes内使用,你需要把\(反斜线)
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);'
and its second part at catch it returns error. check this one please:
runOnUiThread(new Runnable() {
public void run() {
String msg = "File Upload Completed.\n\n See uploaded file here : \n\n"
+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)
这篇关于什么是错的这个code提示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文