troubleshooting Question

How can I get all the string in a java file??

Avatar of hieukhtn
hieukhtn asked on
13 Comments1 Solution262 ViewsLast Modified:
How can I get all the string in a java file.

we have a java class file like this:  -------------------------------------------------------------------------------------------------------------------
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.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros