0
ファイルをhttpサーバにアップロードするのが好きです。これはこれまでのコードです。問題は、ファイルがまったくアップロードされていないことです。コードに何が間違っていますか?ファイルをHttpConnectionにアップロードする - BLACKBERRY/JavaME
更新:私はそれを解決することができました。誰もが同じ問題を抱えていると、おそらくこのコードが役に立ちます。
try{
FileConnection path = (FileConnection)Connector.open(main_directory + "status.zip");
if (!path.exists()) {path.create();}
byte[] buf ;
buf = new byte[(int) path.fileSize()];
in = path.openInputStream();
in.read(buf);
Logger.logEventInfo("FILE INPUT: " + in);
ByteArrayOutputStream outputstream = new ByteArrayOutputStream(buf.length);
Base64OutputStream base64 = new Base64OutputStream(outputstream);
base64.write(buf);
String upload = null; upload = outputstream.toString();
while((length = in.read(buf))> = 0){ bout.write(buf、0、length);でループしています。 } – JohnDoe4136
コードが混乱しています。削除/簡略化できる多くのものが潜在的に存在します。しかし少なくとも行 'String FileUpload = new String(byout.toByteArray()、" UTF8 ");'はうまく見えません。 – BalusC
私はサーバーにアップロードできるように、ファイルを開いて文字列に書き込もうとしています。 – JohnDoe4136