How can I get all the string in a java file.
Example:
we have a java class file like this:
-test.java -------------------------------------------------------------------------------------------------------------------
public class test{
public static void correctString(String sourceFile, String desFile){
String str1 = "Dang Nhon Hoa";
String str2 = "Nguyen Quang Minh";
String str3 = "Test1" + "test2" + "test3";
System.out.print(str3 + str1 + str2 + "test");
}
}
--------------------------------------------------------------------------------------------------------------------------
We have to write a method that read the java file above then return the expected String array content values like this:
returnArrayValues = {"Dang Nhon Hoa", "Nguyen Quang Minh", "Test1", "test2", "test3", "test"};
This mean that all values that considered as String in java will be cacth to this list.
Thanks for your help.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.