How to find the package name given a class name?

后端 未结 5 2074
我在风中等你
我在风中等你 2020-12-19 03:20

Given a class name as a string, how do I get the package name of it at run time ? I do not have the fully qualified name with package name + class name. Simply only the clas

5条回答
  •  情话喂你
    2020-12-19 03:52

    One of the simplest solution:

    Test.class.toString().replace("class", "").replace(".","/").replace(" ", "")
    

提交回复
热议问题