Created
August 17, 2016 07:30
-
-
Save sumitramteke/de2939d303f3594bb3155134faa0c73f to your computer and use it in GitHub Desktop.
List down methods of Java Class
This file contains hidden or 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
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