Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.*;

import javax.xml.transform.*;

import javax.xml.transform.stream.*;

public class Main {

    public static String getXmlFileToString(String filePath) throws TransformerException {
        File xmlFile = new File(filePath);
        StringWriter writer = new StringWriter();
        TransformerFactory fac = TransformerFactory.newInstance();
        Transformer x = fac.newTransformer();
        x.transform(new StreamSource(xmlFile), new StreamResult(writer));
        return writer.toString();
    }
}