All pastes #284167 Raw Edit

Anonymous

public java v1 · immutable
#284167 ·published 2006-12-18 22:23 UTC
rendered paste body
/** *  */package model;import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.Writer;import java.net.HttpURLConnection;import java.net.URL;/** * @author pidi * */public class ServerPostingLabelList {		public LabelList myLabelList;	URL submissionLocation;	static String charsetName = "UTF-8";			public ServerPostingLabelList(URL submissionLocation) {		myLabelList = new LabelList();		this.submissionLocation = submissionLocation;	}		public boolean add(String newLabel) throws IllegalArgumentException {				if (myLabelList.add(newLabel)) {						try {				System.out.println("SUBMISSION: " + this.submissionLocation);								URL serverPostingUrl = this.submissionLocation;								HttpURLConnection postingUrlConnection = (HttpURLConnection) serverPostingUrl.openConnection();								postingUrlConnection.setDoOutput(true);				postingUrlConnection.setRequestMethod("POST");				postingUrlConnection.setRequestProperty(						"Content-Type", "application/x-www-form-urlencoded; charset=" + charsetName);								Writer tempWriter = new OutputStreamWriter(postingUrlConnection.getOutputStream(), charsetName);								System.out.print("Warte auf Server...");								BufferedReader currentBufferedStream;								for (String guess:myLabelList) {					//tempWriter.write("guess=" + guess + "&");					System.out.println(guess);										// TODO BODY															// submissionLocation=http://ailehre.techfak.uni-bielefeld.de/ESPserver/espgame/xftiftuicd&partnerinfoLocation=http://ailehre.techfak.uni-bielefeld.de/ESPserver/espgame/kpaemxclhf&imageLocation=http://ailehre.techfak.uni-bielefeld.de/0607/TdPE/images/00000580.jpg									}												tempWriter.flush();		        tempWriter.close();		        				System.out.println("OK...............");								currentBufferedStream = new BufferedReader(						new InputStreamReader(postingUrlConnection.getInputStream(), charsetName));								System.out.println("OK...............");								System.out.println(currentBufferedStream.readLine());		        		        												postingUrlConnection.disconnect();											}			catch(Exception e) {					        	// Spur des Fehlers wird ausgegeben (Stapel-Speicher)	            System.out.println("");				//e.printStackTrace();	            System.err.println("Fehler beim Empfangen vom Server... (ServerPostingLabelList)");	        }						return true;		}				return false;	}		public boolean contains(Object label) {				if (myLabelList.contains(label)) {						return true;		}				return false;	}		public LabelList match(LabelList otherList) {				return null;	}	}