Created
May 2, 2019 04:41
Searching Online JDK 7 Javadoc API Documentation for string '1.7'
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
#!/usr/bin/env groovy | |
// searchJdk7ApiDocsForSince17.groovy | |
def anchorString = '<a href="' | |
def anchorStringUpper = anchorString.toUpperCase() | |
def urls = new ArrayList<String>() | |
"http://download.oracle.com/javase/7/docs/api/allclasses-frame.html".toURL().eachLine | |
{ | |
def startIndex = -1 | |
if (it.contains(anchorString)) | |
{ | |
startIndex = it.indexOf(anchorString) + anchorString.size() | |
} | |
else if (it.contains(anchorStringUpper)) | |
{ | |
startIndex = it.indexOf(anchorStringUpper) + anchorStringUpper.size() | |
} | |
if (startIndex > -1) | |
{ | |
def endIndex = it.indexOf('"', startIndex) | |
if (endIndex > startIndex) | |
{ | |
def url = it.substring(startIndex, endIndex) | |
urls.add(url) | |
} | |
} | |
} | |
def numUrlsProcessed = 0 | |
def numUrlsMatching = 0 | |
println "${urls.size()} total URLs to search for 1.7 text." | |
def withJava7 = new ArrayList<String>() | |
urls.each | |
{ | |
def match = false | |
numUrlsProcessed++ | |
def eachUrl = "http://download.oracle.com/javase/7/docs/api/${it}" | |
try | |
{ | |
if (eachUrl.toURL().text.contains("1.7")) | |
{ | |
numUrlsMatching++ | |
match = true | |
withJava7.add(it) | |
} | |
} | |
catch (Exception ex) // catch HTTP problems like 404 or 504. | |
{ | |
println "ERROR trying to acces ${eachUrl}: ${ex.toString()}" | |
} | |
println "${numUrlsMatching} of ${numUrlsProcessed} match 1.7 (${match ? eachUrl : '-'})!" | |
} | |
println "Javadoc files with 1.7: " | |
withJava7.each | |
{ | |
println "\t${it}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Featured in blog post "JDK 7: New Interfaces, Classes, Enums, and Methods" on the "Inspired by Actual Events" blog.