Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileReader;
import java.io.IOException;

public class Main {

    public static String xmlFileToString(String path) {
        FileReader reader = null;
        StringBuilder sb = new StringBuilder();
        char[] buf = new char[1024];
        try {
            reader = new FileReader(path);
            int temp = 0;
            while ((temp = reader.read(buf)) != -1) {
                sb.append(String.valueOf(buf, 0, temp));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return sb.toString();
    }
}