Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * @comment_sp Agrega XMLNamespace
     * @comment_ko addXMLNamespace
     * @param source
     * @param xmlNamespace
     * @return
     */
    public static byte[] addXMLNamespace(byte source[], String xmlNamespace) {
        byte oldContent[] = new byte[source.length];
        System.arraycopy(source, 0, oldContent, 0, source.length);
        String s = new String(oldContent);
        String inputNamespace = " xmlns=\"" + xmlNamespace + "\"";
        int start = s.indexOf("?>");
        int fromIndex = s.indexOf("<", start);
        int toIndex = s.indexOf(">", fromIndex);
        StringBuffer sb = new StringBuffer(s);
        sb.insert(toIndex, inputNamespace);
        String input = new String(sb);
        return input.getBytes();
    }
}