aboutsummaryrefslogtreecommitdiff
path: root/src/uk/org/ury/client/Client.java
diff options
context:
space:
mode:
authorMatt Windsor <matt@deling.(none)>2011-03-18 08:28:09 +0000
committerMatt Windsor <matt@deling.(none)>2011-03-18 08:28:09 +0000
commitd547f87da5f68c12dede7c9d45618cae11ff5699 (patch)
tree613aa95d94b363c72ba9a7be639c74f76edf81f8 /src/uk/org/ury/client/Client.java
parentc8bb324e757587e742df0824304144e1eb881cee (diff)
Mega-commit to the rescue! Added Javadoc snapshot (admittedly old); show UI now fixed-layout; UI uses system selection colours for accents; now uses bapsserver password and can thus talk to show database relations; removed member relation dependencies until further notice; attempted to get application and applet launchers working but having issues with the latter; started working on a server communicating via a minimal implementation of HTTP 1.1 (standardisation required eventually).
Diffstat (limited to 'src/uk/org/ury/client/Client.java')
-rw-r--r--src/uk/org/ury/client/Client.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/uk/org/ury/client/Client.java b/src/uk/org/ury/client/Client.java
new file mode 100644
index 0000000..f0b2679
--- /dev/null
+++ b/src/uk/org/ury/client/Client.java
@@ -0,0 +1,65 @@
+package uk.org.ury.client;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Client
+{
+ /**
+ * Get a raw response from the server.
+ *
+ * @param file The "file", including path and query string, to
+ * fetch from the server.
+ *
+ * @return The response from the server, as a List of lines.
+ */
+
+ public List<String>
+ get (String file)
+ {
+ URL url = null;
+ URLConnection uc = null;
+ List<String> result = new ArrayList<String> ();
+
+ try
+ {
+ url = new URL ("http://localhost:8000" + file);
+ }
+ catch (MalformedURLException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace ();
+ }
+
+ try
+ {
+ uc = url.openConnection ();
+
+ BufferedReader in = new BufferedReader (new InputStreamReader
+ (uc.getInputStream ()));
+
+
+ String inputLine;
+
+ for (inputLine = in.readLine();
+ inputLine != null;
+ inputLine = in.readLine())
+ {
+ result.add (inputLine);
+ }
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace ();
+ }
+
+ return result;
+ }
+}