So I am trying to get the data from a line that looks like this:
GET /something HTTP/1.1
Now, I here is my code with the regex:
final ServerSocket server = new ServerSocket(8081);
System.out.println("Listening on port 8081...");
while (true) {
final Socket clientSocket = server.accept();
InputStreamReader isr = new InputStreamReader(clientSocket.getInputStream());
BufferedReader reader = new BufferedReader(isr);
String line = reader.readLine();
Pattern pattern = Pattern.compile("GET \\/(.*?) HTTP");
Matcher m = pattern.matcher(line);
System.out.println(m.find());
the "/something" is what I need to get, and it will always be something different in actual usage. The code always prints out "true", instead of what should be in the string. What am I doing wrong?