Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static final String PREAMBLE_START = "<?xml";
    public static final String PREAMBLE_END = ">";

    public static String findPreamble(final String xml) {
        final int indexStart = xml.indexOf(PREAMBLE_START);

        // make sure we found the encoding attribute
        if (indexStart != -1) {
            final int indexEnd = xml.indexOf(PREAMBLE_END, indexStart + PREAMBLE_START.length());

            // make sure we found the end of the attribute
            if (indexEnd != -1) {
                return xml.substring(indexStart, indexEnd + PREAMBLE_END.length());
            }

        }

        return null;
    }
}