如何确定我的OutputStream内部缓冲(How to determine my OutputStream internally buffered)
OutputStream
是一个抽象类,它包含一个flush()
方法,根据javadoc不执行任何操作。 我知道flush()方法用于推出保留在内部缓冲区中的任何内容。 我知道我需要使用flush(),如果我想确保我写入可能保存在内部缓冲区中的流的所有内容都被发送出去。关键是这可能 。 我如何知道从API接收的流是否正在进行内部缓冲? 如果api的javadoc未明确提及内部缓冲是否正在发生并因此建议使用flush(),该怎么办? 如果我使用返回
OutputStream
的API并且我将字节写入此并且我想确保它们被发送,那么基于“以防它实际上确实有一个调用flush()似乎是浪费内部缓冲区“。
OutputStream
is an abstract class that contains aflush()
method that per the javadoc does nothing. I know that the flush() method is used to push out anything that is kept in internal buffers. I know that I need to use flush() if I want to make sure everything I've written to the stream that might be held in an internal buffer get sent out.The key is this might. How do I know if the stream I receive from an API is doing internal buffering or not? What if the javadoc of the api does not mention explicitly if internal buffering is occurring and hence flush() is recommended? If I'm using an API that returns an
OutputStream
and I write bytes to this and I want to make sure they are sent, it seems like a waste to call flush() on the basis of "just in case it actually does have an internal buffer".
原文:https://stackoverflow.com/questions/45979550
最满意答案
修复错误TypeError:undefined不是函数
你应该改变
context.keys.forEach(context);
oncontext.keys().forEach(context);
因为keys
是功能[1][1] - https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
To fix error TypeError: undefined is not a function
You should change
context.keys.forEach(context);
oncontext.keys().forEach(context);
becausekeys
is function[1][1] - https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/keys
相关问答
更多-
如果要使用这样的导入,则需要设置resolve.alias 。 演示: resolve: { alias: { app: path.join(__dirname, 'app') } } If you want to use an import like that, you'll need to set up a resolve.alias. Demo: resolve: { alias: { app: path.join(__dirname, 'ap ...
-
如何防止karma-webpack创建供应商代码的源地图?(How to prevent karma-webpack from creating source maps of vendor code?)[2022-03-02]
如果有其他人遇到这个问题,我得到了“构建然后休息”的方法,即我放弃了karma-webpack和Karma预处理,转而使用独立的构建和测试命令(它们一个接一个地运行)。 这是我的webpack配置,特定于测试(例如webpack.config.babel.test.js): import webpack from 'webpack'; import { join, resolve, parse } from 'path'; import SplitByPathPlugin from 'webpack-spl ... -
发生这种情况的原因是因为一个循环导入循环。 我只是需要改变代码的运行位置。 (或进口的顺序) The reason this was happening was because a circular import loop. I simply just had to change where the code was running from. (or the order of the imports)
-
你有一对缺少的npm模块。 安装它们: npm install jasmine --save-dev npm install phantomjs --save-dev OTOH,根据常见问题解答,业力0.13在节点5.x上运行。 请参阅此处的最新常见问题 You have a pair of missing npm modules. Install them: npm install jasmine --save-dev npm install phantomjs --save-dev OTOH, ac ...
-
Karma没有开始幻影(Karma not starting phantomJs)[2023-06-17]
文件说 自己捕获浏览器可能是一项繁琐且耗时的任务,因此Karma可以为您自动执行此操作。 只需将要捕获的浏览器添加到配置文件中: browsers: ['Chrome'] 请注意属性的名称:它是browsers ,而不是browser 。 The documentations says Capturing browsers on your own can be a tedious and time consuming task, so Karma can automate this for you. Si ... -
修复错误TypeError:undefined不是函数 你应该改变context.keys.forEach(context); on context.keys().forEach(context); 因为keys是功能[1] [1] - https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/keys To fix error TypeError: undefined is not a func ...
-
希望你能在这里解决你的问题。 我认为webpack配置需要加载器来转换ES6文件,因此您需要webpack.config.test.js文件中的webpack.config.test.js器。 var webpack = require('webpack'); var helpers = require('./helpers'); var config = { devtool: 'inline-source-map', resolve: { root: help ...
-
crypto-browserify库使用的Buffer是缓冲区,是一个修改后的Uint8Array 。 PhantonJS显然有一个拒绝Buffer的错误,这是导致你看到的问题。 我在这里提出了一个问题: https : //github.com/crypto-browserify/crypto-browserify/issues/143 您也可以通过更新crypto-browserify/rng.js暂时修补此crypto-browserify/rng.js以替换此... var bytes = new ...
-
您应该使用Webpack作为预处理器: https : //github.com/webpack/karma-webpack 我个人使用这个,因为它更快: https : //github.com/aaronjensen/karma-webpack 您可能需要在您的业力配置中添加一些polyfills: files: [ './node_modules/babel-polyfill/dist/polyfill.js', './node_modules/phantomjs-polyfill/bind- ...
-
依赖关系路径与当前脚本相关。 所以只需重写你的require语句: var utilities = require('./utilities.js'); Dependencies paths are relative to current script. So just rewrite your require statement: var utilities = require('./utilities.js');