Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将 javax.activation.DataHandler 对象转换为字节数组。最好的方法是什么。是否可以使用 nio 包。
你可以尝试使用这样的东西:
import org.apache.commons.io.IOUtils; DataHandler dataHandler = new DataHandler(); InputStream dataHandler = file.getInputStream(); byte[] arrayByte = IOUtils.toByteArray(dataHandler);