Can I use any USB charger with my iPhone?
If I am understanding you correctly...
A power adapter with a USB port on it will charge anything that that can be charged via USB. So, probably...
That said it is important to note that some USB chargers don't provide enough wattage to charge a device or charge it quickly enough. Also if the usb charger has just a mini/micro USB cable on it then no, as iPhones have *Lightning" connectors not USB connectors.
There is also the issue with cheap, knock-off chargers that are constructed poorly and will damage anything that are plugged into them.
That said a USB charger that is designed to charge a Samsung phone should work as long as it has a standard USB port on it that you can plug a lightning cable into.
USB Charging is a universal standard.
The quality of your cable is more important than the charging brick when it comes to whether your phone will be fine when charging.
As long as you have a MFI certified lightning cable you should be fine. The samsung charger should actually charge you faster than the 5w charger that comes with the XR.
Also FYI in your original question you asked about java for transferring information. Java is a programming language not a protocol.