0

i try to write in a file , which is a share file with url , with the help of URLConnection Class and mostly with the OutputStream of connection. So i write my new bodytext for the file and i put it on the stream. But the file doesn't change. Could you give me some hints or code or tutorial for my problem?

my program seems like this

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();  
  • How does the server side look like? What service are you using on the server side to store your data? You set the Content-Type to `application/x-www-form-urlencoded` which is used for HTML forms but then you just write the data as binary. – nif Jun 29 '13 at 14:48
  • look the file is a share link in a dropbox's folder and it has only a string (timestamp) . In my java application , i take the URLConnection's InputStream and save it to a string . Then , if the string isn't equal to the another string , i want to re - write the file. And in the end i want to re-write the file with the URLConnection's OutputStream. Is my way right ??? – user1417990 Jun 29 '13 at 15:50
  • I might be wrong, but I'm quite sure that you can't just modify any file on Dropbox by POSTing content to the share link. I think you need to use the proper API methods, which are described here: https://www.dropbox.com/developers/core/docs Maybe this helps as well: http://stackoverflow.com/questions/6388439/using-dropbox-java-api-for-uploading-files-to-dropbox – nif Jun 29 '13 at 15:55
  • now i put file in this server [link](http://cgi.di.uoa.gr/~std08081/time/time) and i want to write in this a String. But i haven't any progress . Why ? – user1417990 Jun 30 '13 at 08:02
  • and i have all the rights to the file (read and write ) – user1417990 Jun 30 '13 at 08:23

0 Answers0