我在Windows 7上使用JetBrains WebStorm 11.0.4.我有一个带有Gruntfile.js文件的项目,当我尝试使用WebStorm"重新加载任务"时,WebStorm失败了:
" Grunt窗格中的" 无法列出任务 ".
错误的详细信息是:
Registering "C:\Program Files (x86)\JetBrains\WebStorm 11.0.4\plugins\JavaScriptLanguage\grunt_js\tasks" tasks.
Loading "grunt-tasks-fetcher.js" tasks...ERROR
>> Error: Couldn't find preset "es2015" relative to directory "C:\\Program Files (x86)\\JetBrains\\WebStorm 11.0.4\\plugins\\JavaScriptLanguage\\grunt_js\\tasks"
>> at <my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:395:17
>> at Array.map (native)
>> at OptionManager.resolvePresets (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:387:20)
>> at OptionManager.mergePresets (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:370:10)
>> at OptionManager.mergeOptions (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:330:14)
>> at OptionManager.init (<my_project>\node_modules\babel-core\lib\transformation\file\options\option-manager.js:488:10)
>> at compile (<my_project>\node_modules\babel-register\lib\node.js:112:69)
>> at loader (<my_project>\node_modules\babel-register\lib\node.js:158:14)
>> at Object.require.extensions.(anonymous function) [as .js] (<my_project>\node_modules\babel-register\lib\node.js:168:7)
>> at Module.load (<my_project>\node_modules\coffee-script\lib\coffee-script\register.js:45:36)
>> at Function.Module._load (module.js:314:12)
>> at Module.require …Run Code Online (Sandbox Code Playgroud) 最后,我的最终目标是:
使用以下方法的目标是获取byte[]可在下游用作电子邮件附件的目标(以避免写入磁盘):
public byte[] retrievePDF() {
HttpClient httpClient = new HttpClient();
GetMethod httpGet = new GetMethod("http://website/document.pdf");
httpClient.executeMethod(httpGet);
InputStream is = httpGet.getResponseBodyAsStream();
byte[] byteArray = new byte[(int) httpGet.getResponseContentLength()];
is.read(byteArray, 0, byteArray.length);
return byteArray;
}
Run Code Online (Sandbox Code Playgroud)
对于特定PDF,该getResponseContentLength()方法返回101,689作为长度.的奇怪的是,如果设置了一个断点和询问byteArray变量,它具有101689个字节元素,但是,之后字节#3744的阵列的剩余字节是全零(0). 因此,PDF阅读器客户端(如Adobe Reader)无法读取生成的PDF.
为什么会这样?
通过浏览器检索相同的PDF并保存到磁盘,或者使用如下方法(我在回答此StackOverflow帖子后模式化),得到可读的PDF:
public void retrievePDF() {
FileOutputStream fos = null;
URL url;
ReadableByteChannel rbc = null;
url = new URL("http://website/document.pdf");
DataSource urlDataSource = new URLDataSource(url);
/* …Run Code Online (Sandbox Code Playgroud)