Write delimited file with BOM

Four Stars

Write delimited file with BOM

Hello,

I need to write a file in UTF16-LE with BOM, but the default tFileOutputDelimited component doesn't offer this possibility.

I test a custom component (tWriteHeaderLineToFileWithBOM) but get an error when I execute the processus (see below).

 

Did you have a way to easily add the BOM to such a file? With a component or a working java code?

 

 

 

org.talend.designer.runprocess.ProcessorException: Échec de la génération du code.
	at org.talend.designer.runprocess.java.JavaProcessor.generateCode(JavaProcessor.java:572)
	at org.talend.designer.runprocess.maven.MavenJavaProcessor.generateCode(MavenJavaProcessor.java:71)
	at org.talend.designer.runprocess.ProcessorUtilities.generateContextInfo(ProcessorUtilities.java:687)
	at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:513)
	at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:1418)
	at org.talend.designer.runprocess.RunProcessContext$1.run(RunProcessContext.java:576)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:466)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:374)
	at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:527)
	at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:284)
	at org.eclipse.ui.internal.progress.ProgressManager.run(ProgressManager.java:1190)
	at org.talend.designer.runprocess.RunProcessContext.exec(RunProcessContext.java:531)
	at org.talend.designer.runprocess.remote.RunRemoteProcessContext.exec(RunRemoteProcessContext.java:71)
	at org.talend.designer.runprocess.ui.ProcessComposite.exec(ProcessComposite.java:1450)
	at org.talend.designer.runprocess.ui.views.ProcessView$RunAction.run(ProcessView.java:691)
	at org.talend.designer.runprocess.ui.actions.RunProcessAction.run(RunProcessAction.java:58)
	at org.talend.designer.core.debug.JobLaunchConfigurationDelegate$1.run(JobLaunchConfigurationDelegate.java:84)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4147)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3764)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.talend.rcp.intro.Application.start(Application.java:255)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
Caused by: org.talend.designer.codegen.exception.CodeGeneratorException: ----------
1. ERROR in D:\Users\pellfr01\workspace_bis\.JETEmitters\src\org\talend\designer\codegen\translators\file\output\TWriteHeaderLineToFileWithBOMMainJava.java (at line 185)
	if (codeGenArgument.subTreeContainsParallelIterate()) {
	                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The method subTreeContainsParallelIterate() is undefined for the type CodeGeneratorArgument
----------
2. ERROR in D:\Users\pellfr01\workspace_bis\.JETEmitters\src\org\talend\designer\codegen\translators\file\output\TWriteHeaderLineToFileWithBOMMainJava.java (at line 243)
	if (codeGenArgument.subTreeContainsParallelIterate()) {
	                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The method subTreeContainsParallelIterate() is undefined for the type CodeGeneratorArgument
----------
2 problems (2 errors)

	at org.talend.designer.codegen.CodeGenerator.generateComponentCode(CodeGenerator.java:757)
	at org.talend.designer.codegen.CodeGenerator.generateComponentsCode(CodeGenerator.java:536)
	at org.talend.designer.codegen.CodeGenerator.generateComponentsCode(CodeGenerator.java:482)
	at org.talend.designer.codegen.CodeGenerator.generateProcessCode(CodeGenerator.java:226)
	at org.talend.designer.runprocess.java.JavaProcessor.generateCode(JavaProcessor.java:569)
	... 41 more
Community Manager

Re: Write delimited file with BOM

Hello
Here is a related topic that introduces how to use this custom component.
https://community.talend.com/t5/Design-and-Development/Is-there-an-UTF8-encoding-type-with-BOM/m-p/8...

Hope it helps!

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Four Stars

Re: Write delimited file with BOM

Thanks, but even if I follow the explanations post in this thread, I always get the same error message post above.

Ten Stars

Re: Write delimited file with BOM

To workaround this issue, I've created a static header file with BOM that I copy and rename in the output directory.  Appending records to the existing header preserves the BOM.