Skip to content

Instantly share code, notes, and snippets.

@tuzzeg
Created August 2, 2016 05:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuzzeg/4253d9036639477ee4422a0629515d49 to your computer and use it in GitHub Desktop.
Save tuzzeg/4253d9036639477ee4422a0629515d49 to your computer and use it in GitHub Desktop.
Using LinkedIn URL detector
import com.linkedin.urls.Url;
import com.linkedin.urls.detection.UrlDetector;
import com.linkedin.urls.detection.UrlDetectorOptions;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Scanner;
final class FindUrls {
public static void main(String args[]) throws IOException {
try (BufferedReader in = new BufferedReader(
new InputStreamReader(System.in, StandardCharsets.UTF_8))) {
String line;
while ((line = in.readLine()) != null) {
UrlDetector parser = new UrlDetector(line, UrlDetectorOptions.Default);
List<Url> found = parser.detect();
for(Url url : found) {
System.out.println("URL: " + url.getFullUrl());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment