I have 3rd party library function which only takes Reader as parameter. And I have String that I need to pass into function. How do I do that ?
String s = "Some String";
StringReader sReader = new StringReader(s);
// 3rd Party Function Definition is public File saveResult(Reader source);
Can I do as File aFile = saveResult(sReader); ? Or Should I create buffer and call read() first ?
I tried both way, and I am keep getting null pointer exception.
Hope this should be enough to serve your purpose:
String string = "Some String";
StringReader stringReader = new StringReader(string);
File fileName = saveResult(stringReader); // calling Third party library method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With