对于Transformer.setOutputProperty感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍OutputKeys.ENCODING,“UTF-8”无法正常工作,并为您提供关于A
对于Transformer.setOutputProperty感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍OutputKeys.ENCODING,“ UTF-8”无法正常工作,并为您提供关于Angular2的input和output(原先的properties和events)、autohotkey 如何循环读取waterfall_output\output.txt内容,一行一行的,当前加循环不起作用。感谢!、Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Dec、Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorate...的有用信息。
本文目录一览:- Transformer.setOutputProperty(OutputKeys.ENCODING,“ UTF-8”)无法正常工作(无法运行format)
- Angular2的input和output(原先的properties和events)
- autohotkey 如何循环读取waterfall_output\output.txt内容,一行一行的,当前加循环不起作用。感谢!
- Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Dec
- Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorate...
Transformer.setOutputProperty(OutputKeys.ENCODING,“ UTF-8”)无法正常工作(无法运行format)
我有以下方法将XMLDom写入流:
public void writeToOutputStream(Document fDoc, OutputStream out) throws Exception { fDoc.setXmlStandalone(true); DOMSource docSource = new DOMSource(fDoc); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.INDENT, "no"); transformer.transform(docSource, new StreamResult(out));}
我正在测试其他XML功能,而这只是我用来写入文件的方法。我的测试程序生成了33个测试用例,其中文件被写出。其中28个具有以下标头:
<?xml version="1.0" encoding="UTF-8"?>...
但是由于某种原因,现在有一个测试用例产生:
<?xml version="1.0" encoding="ISO-8859-1"?>...
还有另外四个产品:
<?xml version="1.0" encoding="Windows-1252"?>...
如您所见,我将ENCODING输出键设置为UTF-8。这些测试过去可用于Java的早期版本。我已经有一段时间(一年多了)没有运行测试,但是今天在“
Java(TM)SE运行时环境(内部版本1.6.0_22-b04)”上运行,我得到了这种有趣的行为。
我已经验证了导致该问题的文档是从最初具有这些编码的文件中读取的。似乎新版本的库正在尝试保留已读取的源文件的编码。但这不是我想要的……我确实希望输出为UTF-8。
有谁知道其他因素可能导致变压器忽略UTF-8编码设置?还需要在文档上设置其他内容,以忘记最初读取的文件的编码吗?
更新:
我在另一台计算机上签出了相同的项目,并在那里进行了测试。在那台机器上,所有测试均通过!所有文件的标题中都带有“ UTF-8”。该机器具有“
Java™SE运行时环境(内部版本1.6.0_29-b11)”,两台计算机都运行Windows7。在可以正常工作的新机器上,使用jdk1.5.0_11进行了构建,但是在旧机器上机器jdk1.6.0_26用于进行构建。这两个版本使用的库完全相同。在构建时是否可能与JDK
1.6不兼容1.5?
更新:
4.5年后,Java库仍然损坏,但是由于以下Vyrx的建议,我终于有了一个适当的解决方案!
public void writeToOutputStream(Document fDoc, OutputStream out) throws Exception { fDoc.setXmlStandalone(true); DOMSource docSource = new DOMSource(fDoc); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); transformer.setOutputProperty(OutputKeys.INDENT, "no"); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>".getBytes("UTF-8")); transformer.transform(docSource, new StreamResult(out));}
解决方案是禁用标题的编写,并在将XML序列化到输出流之前,编写正确的标题。me脚,但它产生正确的结果。超过4年前的测试现在又可以运行!
答案1
小编典典序列化表情符号字符时,我在Android上遇到相同的问题。在转换器中使用UTF-8编码时,输出为HTML字符实体(UTF-16代理对),这些实体随后将破坏读取数据的其他解析器。
这就是我最终解决它的方式:
StringWriter sw = new StringWriter();sw.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");Transformer t = TransformerFactory.newInstance().newTransformer();// this will work because we are creating a Java string, not writing to an outputt.setOutputProperty(OutputKeys.ENCODING, "UTF-16"); t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");t.transform(new DOMSource(elementNode), new StreamResult(sw));return IOUtils.toInputStream(sw.toString(), Charset.forName("UTF-8"));
Angular2的input和output(原先的properties和events)
angular2学习笔记
本文地址:http://blog.csdn.net/sushengmiyan
本文作者:苏生米沿
文章来源:http://blog.ng-book.com/angular-2-component-inputs-and-inputs-formerly-properties-and-events/
angular2的开发迭代笔记快,其中一个重大API变化就是组件(components)现在有input和outputs了。
过去,我们这样定义一个组件:
@Component({ selector: 'my-component',properties: ['product'],events: ['onAdd'] }}
现在不一样了:
@Component({ selector: 'my-component',inputs: ['product'],outputs: ['onAdd'] }}
这个API的改动是有争议的,不过它也是有意义的。
关于这个争议,在git上有激烈的讨论,感兴趣的可以看下:
https://github.com/angular/angular/pull/4435#issuecomment-144789359
autohotkey 如何循环读取waterfall_output\output.txt内容,一行一行的,当前加循环不起作用。感谢!
Loop,D:\Z\waterfall_output\output.txt
{
FileRead, File_Path, D:\Z\waterfall_output\output.txt
Send,!FO
clipboard = %File_Path%
Send ^v
sleep,3000
Send,!O
,截图前停留2s
sleep,2000
Send,!BS
}
Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Dec
Android Gradle 升级到 3.0 更改输出的 Apk 安装包的名字 报错
Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=xiaomiDebug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
项目原来的代码
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(''.apk'')){
def fileName = outputFile.name.replace(".apk",
"-${defaultConfig.versionName}.apk")
output.outputFile = new File(outputFile.parent,fileName)
}
}
}
更改后的
applicationVariants.all { variant ->
variant.outputs.all { output ->
def fileName
if (outputFile != null && outputFile.name.endsWith(''.apk'')) {
fileName = outputFile.name.replace(".apk", "-${defaultConfig.versionName}.apk")
outputFileName = fileName
}
}
}
Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorate...
转载请标明出处:https://www.cnblogs.com/tangZH/p/10764568.html
更多精彩文章:http://77blogs.com/?p=298
在做多渠道打包的时候出现了这个错误,在高版本的gradle出现。
具体错误为:Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
我的代码为下:
这个在低版本的gradle是行得通的,但是高版本就不行。
高版本的应该这样:
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(''proguard-android-optimize.txt''),
''proguard-rules.pro''
applicationVariants.all { variant ->
variant.outputs.all { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(''.apk'')) {
def fileName = "novel_v${defaultConfig.versionName}_${releaseTime()}_${variant.productFlavors[0].name}.apk"
outputFileName = fileName
}
}
}
}
}
将variant.outputs.each改为variant.outputs.all
将output.outputFile = new File(outputFile.parent, fileName)改为outputFileName = fileName
关于Transformer.setOutputProperty和OutputKeys.ENCODING,“ UTF-8”无法正常工作的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于Angular2的input和output(原先的properties和events)、autohotkey 如何循环读取waterfall_output\output.txt内容,一行一行的,当前加循环不起作用。感谢!、Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Dec、Cannot set the value of read-only property ''outputFile'' for ApkVariantOutputImpl_Decorate...的相关信息,请在本站寻找。
本文标签: