dont leech
Active Member
- Joined
- Aug 12, 2008
- Sythe Gold
- 0
- Messages
- 186
I want to write text in a txt doc that is located in a webserver.
Here is my code:
it throws IOExeption, what im i doing wrong?
Here is my code:
Code:
public static void hey(){
URL url = null;
URLConnection urlConn = null;
DataOutputStream dos = null;
DataInputStream dis = null;
try {
url = new URL("URL/.TXT");
urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
urlConn.setRequestProperty ("Content-Type", "application/x-www-form-urlencoded");
dos = new DataOutputStream (urlConn.getOutputStream());
String message = "NEW_ITEM=" + username + password;
dos.writeBytes(message);
dos.flush();
dos.close();
dis = new DataInputStream(urlConn.getInputStream());
String s = dis.readLine();
dis.close();
}
catch (MalformedURLException mue) {
System.out.print("malformed url");
}
catch (IOException ioe) {
System.out.print("IOEXCEPTION");
}
}
it throws IOExeption, what im i doing wrong?