vendredi 15 avril 2016

How to change certain Strings in class file?

How I read Strings in Java class:

public static void main(String args[]) {
    Utils uuiDd = new Utils();
    Field[] fields = uuiDd.getClass().getDeclaredFields();
    for (Field field : fields){
        if (field.getType().equals(String.class)){
            System.out.println("Variable name: " + field.getName());
            field.setAccessible(true);
            try {
                System.out.println("Variable value: " + field.get(uuiDd));
            } catch (Exception e) { e.printStackTrace(); }
        }
    }
}

It's okay, but how to write edited Strings back in class file? And how to load external class file in memory?





Aucun commentaire:

Enregistrer un commentaire