Skip to content

Instantly share code, notes, and snippets.

@sumitramteke
Created August 17, 2016 07:30
Show Gist options
  • Save sumitramteke/de2939d303f3594bb3155134faa0c73f to your computer and use it in GitHub Desktop.
Save sumitramteke/de2939d303f3594bb3155134faa0c73f to your computer and use it in GitHub Desktop.
List down methods of Java Class
package sumitramteke;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.regex.Pattern;
import java.util.stream.Stream;
public class ListOfMethod {
public static void main(String[] args) {
String fileName = "MYJavaFilePath.java";
Pattern p = Pattern.compile("(public|private).*\\)");
//read file into stream, try-with-resources
try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
stream
.filter(line -> p.matcher(line).find())
.forEach(line -> System.out.println(
line.substring(line.indexOf('p'))
));
} catch (IOException e) {
e.printStackTrace();
}
}
public static String fileToString(File file) {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment