Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Blackberry 如何通过http将文件上传到网站?(黑莓手机)_Blackberry_Jde - Fatal编程技术网

Blackberry 如何通过http将文件上传到网站?(黑莓手机)

Blackberry 如何通过http将文件上传到网站?(黑莓手机),blackberry,jde,Blackberry,Jde,我需要通过http或ftp将文件上载到blackberry jde中的网站。高级视图:从打开一个输出流,并将数据写入该输出流。主要的问题是选择要使用的网络连接(我建议查看。至于通过FTP上传,这将有点困难,因为BlackBerry API中没有内置FTP的支持,相反,您必须查看FTP的使用和实现部分 以下是一些让您开始学习的代码: HttpConnection httpConn = (HttpConnection) Connector.open("<URL>"); FileConne

我需要通过http或ftp将文件上载到blackberry jde中的网站。

高级视图:从打开一个输出流,并将数据写入该输出流。主要的问题是选择要使用的网络连接(我建议查看。至于通过FTP上传,这将有点困难,因为BlackBerry API中没有内置FTP的支持,相反,您必须查看FTP的使用和实现部分

以下是一些让您开始学习的代码:

HttpConnection httpConn = (HttpConnection) Connector.open("<URL>");
FileConnection fileConn = (FileConnection) Connector.open("file:///<path>");
InputStream in = fileConn.openInputStream();
OutputStream out = httpConn.openOutputStream();
byte[] buffer = new byte[100];
int bytesRead = 0;
while((in.read(buffer) = bytesRead) > 0)
{
   out.write(buffer, 0, bytesRead);
}
HttpConnection-httpConn=(HttpConnection)连接器。打开(“”);
FileConnection fileConn=(FileConnection)Connector.open(“文件://”);
InputStream in=fileConn.openInputStream();
OutputStream out=httpConn.openOutputStream();
字节[]缓冲区=新字节[100];
int字节读取=0;
while((in.read(buffer)=bytesRead)>0)
{
out.write(缓冲区,0,字节读取);
}

当然,您需要处理异常,关闭流,检查它是否已成功上载,等等

我可能是错的,但这在HTTP表单帖子上不起作用。您仍然需要有HTTP头,如类型和长度以及边界字符串。对吗?是否对
InputStream中的
InputStream中的数据长度存在一些限制?