Documentum DFC: How to get custom attributes

Here is a way to get all the custom attributes of an object in DFC without knowing them ahead of time:

                //Custom Attributes
                String allAttributes = dctmFileObject.dump();
                String customAttributes = allAttributes.substring(allAttributes.indexOf("language_code"), allAttributes.indexOf("SYSTEM ATTRIBUTES"));
                try (BufferedReader reader = new BufferedReader(new StringReader(customAttributes))) {
                    String line = reader.readLine().trim();
                    while (line != null && !line.isEmpty()) {
                        String attributeName = line.substring(0, line.indexOf(':')).trim();
                        String attributeValue = line.substring(line.indexOf(':')).trim();
                        int attributeDataType = dctmFileObject.getAttr(dctmFileObject.findAttrIndex(attributeName)).getDataType();

                        line = reader.readLine();
                } catch (IOException exc) {
                    // quit