(这是x-post到Jsch邮件列表BTW).我正在从数据库中读取数据并将其作为byte [](用于跨中间件组件传输).
从那个字节[]我知道如何使用GZIPOutputStream类在本地文件系统上创建一个gzip压缩文件.我想要做的是使用JSch SFTP方法在远程文件系统上创建一个gzip压缩文件.
我已经解压缩了数据的byte []并将其作为InputStream传递给JSch库,以便SFTP到远程文件目录(作为.gz文件).但是,传递的文件具有意外的EOF并且不能被"枪杀"
gunzip:GlobalIssuer.xml.gz:意外的文件结束
提醒我没有传输一个字节[],它是.gz文件的内容,它是数据库记录的内容
(相对)SSCCE如下:
byte[] content = "Content".getBytes();
// It does work (I promise!) returns a 'gzipped' byte[]
byte[] gzippedContent = gzipContent(content);
ByteArrayInputStream bais = new ByteArrayInputStream(gzippedContent);
channelSftp.put(bais, "Content.txt.gz");
Run Code Online (Sandbox Code Playgroud)
gzipContent方法:
private byte[] gzipContent(byte[] content)
{
ByteArrayInputStream in = new ByteArrayInputStream(content);
// Create stream to compress data and write it to the to file.
GZIPOutputStream gzipOutputStream = null;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try
{
gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream);
byte[] buffer = new byte[4096];
int …Run Code Online (Sandbox Code Playgroud) 这里的Java工程师,Javascript世界的新手,如果我没有提供足够/正确的信息,请道歉!
我有一个gulp构建脚本,并使用bower来管理我的JS前端应用程序的依赖项.我正在努力让(凉亭控制的)供应商javascript库以正确的顺序连接起来,以便jQuery和angular首先出现.
如果它们不是第一个,那么我得到角度是未定义的,或者当我加载我的应用程序时jQuery是未定义的,因为它们相应的javascript代码被隐藏在连接库中的某个地方.
我试图用来gulp-order命令结果main-bower-files调用的输出,但似乎没有效果.
我的gulp任务如下:
gulp.task('lib', function () {
var files =
gulp.src(mainBowerFiles({
paths: {
bowerrc: './.bowerrc',
bowerJson: './bower.json'
}, env: 'lib'}))
.pipe(order(["vendor/bower/jquery/**/*.js", "vendor/bower/angular/**/*.js", "vendor/bower/**/*.js" ]))
return processJsFiles('lib', files);
});
Run Code Online (Sandbox Code Playgroud)
processJsFiles执行uglify工作,看起来非常像:
.pipe(uglify(name + '.js', {
outSourceMap: true,
screwIe8: true,
compress: {
hoist_funs: false,
if_return: false
}
}))
.pipe(gulp.dest(build_dir))
.pipe(gzip())
.pipe(gulp.dest(build_dir));
Run Code Online (Sandbox Code Playgroud)
我应该做的任何线索或更好的方法吗?
我正在试图弄清楚如何使用XPath从以下XML文档中的XML片段中获取exceptionID和instrumentID值(是的,CDATA中的XML有点奇怪,但这是我从第三方服务获得的)
<?xml version="1.0"?>
<exception>
<info>
<![CDATA[
<info>
<exceptionID>1</exceptionID>
<instrumentID>1</instrumentID>
</info>
]]>
</info>
</exception>
Run Code Online (Sandbox Code Playgroud)
是否可以在一个XPath语句中获取值?
我在Java中使用javax.xml.xpath.XPath(JDK 1.5 with Xalan 2.7.1和Xerces 2.9.1),例如
XPath xpath = XPathFactory.newInstance().newXPath();
Long exceptionId = new Long(((Double)xpath.evaluate(this.exceptionIdXPath,
document, XPathConstants.NUMBER)).longValue());
Run Code Online (Sandbox Code Playgroud)
这是this.exceptionIdXPath变量,我不知道如何设置,我知道例如:
/exception/info/text()/info/exceptionID 将无法正常工作(text()返回CDATA内的数据,但没有"知识"它是XML)