1

我想写入流并立即使用它,而不是将其写入文件并读取。文件不是线程安全的,我认为它可能会影响性能。

    //set property to an existing file
    prop.setProperty("$quoteValidity",""no");
    prop.setProperty("$date", "today");
    prop.setProperty("$quantitySum",  Integer.toString(quantitySum));

    //store it in temporary location
    prop.store(new FileOutputStream("<Temp file location>"), null);

    //open that temp file as stream
    InputStream propfile = new FileInputStream("<Temp file location>");

    List<Order> orderList = XmlToList.makeOrderFromNodeList(orderNode);
    //use that temp file
    Testground.generateXlsx(propfile,orderList);
4

1 回答 1

1

尝试使用 ByteArrayOutputStream 而不是 FileOutputStream。然后你可以打电话

 byte[] bytes=byteArrayOutputStream.toByteArray() 

在 ByteArrayOutputStream 上获取字节

然后构造一个 ByteArrayInputStream(bytes) 并将其传递给 Testground

于 2012-06-27T14:11:21.467 回答