Created
August 2, 2016 05:27
-
-
Save tuzzeg/4253d9036639477ee4422a0629515d49 to your computer and use it in GitHub Desktop.
Using LinkedIn URL detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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