From 23a46b4be35277e06ec89f48730eeb694e686be8 Mon Sep 17 00:00:00 2001
From: Kenmegne <stephanie.kenmegne@gmail.com>
Date: Thu, 18 Jun 2026 15:40:06 +0000
Subject: [PATCH] add fdx-commons and fdx-consultation

---
 fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/jaxb/util/JaxBUtil.java |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/jaxb/util/JaxBUtil.java b/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/jaxb/util/JaxBUtil.java
new file mode 100644
index 0000000..b66a62c
--- /dev/null
+++ b/fdx-commons/fdxcommons-tools/src/main/java/com/megatim/fdxcommons/tools/jaxb/util/JaxBUtil.java
@@ -0,0 +1,40 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.megatim.fdxcommons.tools.jaxb.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+/**
+ *
+ * @author ASUS
+ */
+public class JaxBUtil {
+
+    public static <T> T convertXmlFileToObject(String fileName, Class<T> clazz) throws Exception {
+        JAXBContext context = JAXBContext.newInstance(clazz);
+        Unmarshaller unmarshaller = context.createUnmarshaller();
+        InputStream inputStream = new FileInputStream(fileName);
+        Reader reader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
+        BufferedReader buffer = new BufferedReader(reader);
+        return (T) unmarshaller.unmarshal(buffer);
+    }
+
+    public static void buildXmlFile(Class clazz, String fileName, Object valueToWrite) throws JAXBException {
+        JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
+        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
+        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        jaxbMarshaller.marshal(valueToWrite, new File(fileName));
+    }
+}

--
Gitblit v1.10.0