我尝试在 URLConnection 类的帮助下写入一个文件,这是一个带有 url 的共享文件,主要是在连接的 OutputStream 的帮助下。因此,我为该文件编写了新的正文并将其放在流中。但文件没有改变。你能给我一些提示或代码或教程来解决我的问题吗?
我的程序看起来像这样
connectionWrite = (HttpURLConnection) new URL(locationFile).openConnection();
connectionWrite.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connectionWrite.setDoOutput(true);
connectionWrite.setUseCaches(false);
((HttpURLConnection) connectionWrite).setRequestMethod("POST");
connectionWrite.setRequestProperty("Content-Type", "MultiPart/Form-Data");
//connectionWrite.setRequestProperty("Connection", "Keep-Alive");
byte bytes[] = String.valueOf(stamp).getBytes();
connectionWrite.setRequestProperty("Content-length", "" + bytes.length);
connectionWrite.connect();
OutputStream out = connectionWrite.getOutputStream();
out.write(bytes);
out.flush();