Skip to main content
Question

I cannot download the empty file txt using Java SDK

  • May 23, 2025
  • 1 reply
  • 17 views

Forum|alt.badge.img
BoxFile file = new BoxFile(boxAPIConnection, "Some-id");
try (FileOutputStream stream = new FileOutputStream(fi)) {
file.download(stream);
// Do Sth
}

At the line file.download(stream) I got an error

java.lang.NullPointerException: Cannot invoke "java.io.InputStream.read(byte[])" because "input" is null
    at com.box.sdk.BinaryBodyUtils.writeStreamTo(BinaryBodyUtils.java:55)
    at com.box.sdk.BinaryBodyUtils.writeStream(BinaryBodyUtils.java:41)
    at com.box.sdk.BoxFile.download(BoxFile.java:311)
  at com.box.sdk.BoxFile.download(BoxFile.java:298)
 
I look at the lib of box sdk and see that this line got nullpointer exception beacause the input is null. This only happens when I try to upload an empty txt file then download it.
mdw01HMQKY1ABW6KNPN5V1KG0YKHN.png

1 reply

Forum|alt.badge.img

Hi there,

Welcome to Box Community and glad to assist! 

Let me create a new case and a member of our team will be in touch, please keep an eye out.

Thanks for posting!