| Auszug |
|---|
|
Nuclos FileProvider: print, save, newFile, NuclosFile, printer, output format, byte[]. |
Language: Deutsch · English
FileProvider
Print, save and create NuclosFiles from byte arrays.
| Status |
|---|
| colour | Green |
|---|
| title | Updated: Jul 2026 |
|---|
|
| Status |
|---|
| colour | Grey |
|---|
| title | applies to Nuclos 4.2026.x |
|---|
|
What is the FileProvider for?
The FileProvider contains methods to process NuclosFiles – printing, saving on the server and converting.
| Info |
|---|
|
Only NuclosFiles in the output format File or Screen can be stored as attachments. For the printer the format (default) printer client/server is required – possibly two output formats per report/form. |
print(file[, printername])
Sends the NuclosFile to the default or a named printer.
| Codeblock |
|---|
|
public static void print(NuclosFile file) throws BusinessException;
public static void print(NuclosFile file, String printername) throws BusinessException; |
save(file, directory)
Saves the NuclosFile on the server in the given directory.
| Codeblock |
|---|
|
public static void save(NuclosFile file, String directory) throws BusinessException; |
| Codeblock |
|---|
|
package org.nuclet.businessentity;
import org.nuclet.printout.FormularAbschlussAuftragPO;
import org.nuclos.api.common.NuclosFile;
import org.nuclos.api.provider.PrintoutProvider;
import org.nuclos.api.provider.FileProvider;
public class AbschlussAuftragRegel implements InsertFinalRule {
public void insertFinal(InsertContext context) throws BusinessException {
Auftrag a = context.getBusinessObject(Auftrag.class);
NuclosFile result = PrintoutProvider.run(FormularAbschlussAuftragPO.Deutsch_PDF, a.getId());
// store file in FTP-Directory
FileProvider.save(result, "/home/ftp/");
// Print file on default printer
FileProvider.print(result);
}
} |
Convert byte[] to NuclosFile
Use FileProvider.newFile(File) to turn a byte array into a NuclosFile:
| Codeblock |
|---|
|
public static NuclosFile writeArrayToNuclosFile(String filename, byte[] content) throws BusinessException {
File file = null;
try {
file = new File(filename);
FileUtils.writeByteArrayToFile(file, content);
return FileProvider.newFile(file);
} catch (IOException exception) {
throw new BusinessException("Fehler beim Erzeugen der Datei " + file.getName() + ": " + exception.getMessage());
}
} |
Related pages
QueryProvider
Daten laden.
Open →
BusinessObjectProvider
BOs schreiben.
Open →
DatasourceProvider
run data sources.
Open →