You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everyone, I would love like to extract all Java Methods in a Java File as mentioned in the title of this question.
To give an example of what I mean
i.e.. the file myFile.java contains the following code
System.out.print("test123")
public static List<String> getLinks(String url) throws IOException {
List<String> result = new ArrayList<String>();
Document doc = Jsoup.connect(url).get();
Elements links = doc.select("a");
for (Element link : links) {
result.add(link.absUrl("href"));
}
return result;
}
public static List<String> getLinksV2(String url) throws BadRequest {
try {
URL aUrl= new URL(url);
String host = aUrl.getHost();
System.out.println(host);
if (host.startsWith("172.") || host.startsWith("192.168") || host.startsWith("10.")){
throw new BadRequest("Use of Private IP");
} else {
return getLinks(url);
}
} catch(Exception e) {
throw new BadRequest(e.getMessage());
}
}
Given the following code, I should be able to get back the 2 methods entirely (including the method header, body and return statement etc)
P.S. I am not sure if Javalang is the best tool for this, but I am certainly open to other tools. I have tried using REGEX and python script but it is not very accurate. I am open to any other command-line tools as well.
The primary goal I have is to be able to have the list of methods that is within a java file.
P.S. Please suggest any tools to me for this purpose! I would really appreciate it!
Thanks in advanced!
The text was updated successfully, but these errors were encountered:
@cyberjj999 I've answered in your previous question. Hope, it's what you need.
There also CDT framework (it's written on Java, Eclipse's framework). IT can do much more that the current framework.
Or you can find Java parser https://javaparser.org/.
I believe there is no Python framework which can parse Java code
Hi everyone, I would love like to extract all Java Methods in a Java File as mentioned in the title of this question.
To give an example of what I mean
i.e.. the file myFile.java contains the following code
Given the following code, I should be able to get back the 2 methods entirely (including the method header, body and return statement etc)
P.S. I am not sure if Javalang is the best tool for this, but I am certainly open to other tools. I have tried using REGEX and python script but it is not very accurate. I am open to any other command-line tools as well.
The primary goal I have is to be able to have the list of methods that is within a java file.
P.S. Please suggest any tools to me for this purpose! I would really appreciate it!
Thanks in advanced!
The text was updated successfully, but these errors were encountered: