how to create a file and write on it on URL
HI can anybody tell me how to create a file and write on it on the URl.
Actually I am using an applet and from theat I want to create a file on getCodebase(); so can any body tell me how can I do it
I have tried
URL url = new URL(/*url by codebase and the directory with file name*/);
URLConnection connection = url.openConnection开发者_JAVA技巧();
connection.setDoOutput(true);
OutputStream out = connection.getOutputStream();
but it not worked
Please help me
Actually I am using an applet and from theat I want to create a file on getCodebase();
Well that wouldn't be very secure if you could do that, would it?
I think the route you want to take is to configure your HTTP server to handle PUT requests, and then form a PUT in Java. That is described here:
- How to send PUT, DELETE HTTP request in HttpURLConnection?
However, your applet probably needs elevated permissions (in other words, a signed applet that operates outside of the normal sandbox). I'm not sure about that though; some connections are allowed back to the host so you might be OK.
精彩评论