How to execute adb commands programatically using Appium Java

I need to execute the adb commands in my java program to perform certain actions in the Android app but unfortunately I didn’t find a way to do that. How can I achieve this using Appium Java. Is ProcessBuilder the only way to achieve this or do we have any other way to achieve this. Kindly assist.

Go with the ProcessBuilder alternative. I also redirect the output so that I can have access to the response from commands