Here you can find the source of inheritGwtModule(Path path, String inheritableModuleLogicalName)
Parameter | Description |
---|---|
path | GWT module descriptor |
inheritableModuleLogicalName | logical name of the GWT module to inherit |
Parameter | Description |
---|
public static void inheritGwtModule(Path path, String inheritableModuleLogicalName) throws IOException
//package com.java2s; /******************************************************************************* * Copyright (c) 2012-2015 Codenvy, S.A. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/* w w w. j a v a 2s . c o m*/ * Codenvy, S.A. - initial API and implementation *******************************************************************************/ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.List; import static java.nio.charset.StandardCharsets.UTF_8; public class Main { /** * Inherit the specified module name in the provided GWT module descriptor. * * @param path * GWT module descriptor * @param inheritableModuleLogicalName * logical name of the GWT module to inherit * @throws java.io.IOException * error occurred while reading or writing content of file */ public static void inheritGwtModule(Path path, String inheritableModuleLogicalName) throws IOException { final String inheritsString = " <inherits name='" + inheritableModuleLogicalName + "'/>"; List<String> content = Files.readAllLines(path, UTF_8); // insert custom module as last 'inherits' entry int i = 0, lastInheritsLine = 0; for (String str : content) { i++; if (str.contains("<inherits")) { lastInheritsLine = i; } } content.add(lastInheritsLine, inheritsString); Files.write(path, content, UTF_8); } }