本文整理汇总了Java中com.helger.commons.io.stream.StreamHelper.writeStream方法的典型用法代码示例。如果您正苦于以下问题:Java StreamHelper.writeStream方法的具体用法?Java StreamHelper.writeStream怎么用?Java StreamHelper.writeStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.helger.commons.io.stream.StreamHelper
的用法示例。
在下文中一共展示了StreamHelper.writeStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeFile
import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
/**
* Helper function for saving a file with correct error handling.
*
* @param sRelativePath
* name of the file. May not be <code>null</code>.
* @param eAppend
* Appending mode. May not be <code>null</code>.
* @param aBytes
* the bytes to be written. May not be <code>null</code>.
* @return {@link ESuccess}
*/
@Nonnull
default ESuccess writeFile (@Nonnull final String sRelativePath,
@Nonnull final EAppend eAppend,
@Nonnull final byte [] aBytes)
{
// save to file
final OutputStream aOS = getOutputStream (sRelativePath, eAppend);
if (aOS == null)
return ESuccess.FAILURE;
// Close the OS automatically!
return StreamHelper.writeStream (aOS, aBytes);
}
示例2: writeFile
import com.helger.commons.io.stream.StreamHelper; //导入方法依赖的package包/类
@Nonnull
public static ESuccess writeFile (@Nonnull final File aFile,
@Nonnull final byte [] aContent,
@Nonnegative final int nOffset,
@Nonnegative final int nLength)
{
final OutputStream aFOS = FileHelper.getOutputStream (aFile);
return aFOS == null ? ESuccess.FAILURE : StreamHelper.writeStream (aFOS, aContent, nOffset, nLength);
}