Here you can find the source of getManifestEntryValue(IResource manifest, String entryKey)
private static String getManifestEntryValue(IResource manifest, String entryKey)
//package com.java2s; /*//from ww w.j a v a2 s . c o m * Copyright (C) 2003-2014 Pascal Essiembre * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.StringTokenizer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; public class Main { private static String getManifestEntryValue(IResource manifest, String entryKey) { if (manifest instanceof IFile) { String content = getFileContent((IFile) manifest, "UTF8"); int index = content.indexOf(entryKey); if (index != -1) { StringTokenizer st = new StringTokenizer( content.substring(index + entryKey.length()), ";:\r\n"); return st.nextToken().trim(); } } return null; } /** * Returns the file content as UTF8 string. * * @param file * @param charset * @return */ public static String getFileContent(IFile file, String charset) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); InputStream in = null; try { in = file.getContents(true); byte[] buf = new byte[8000]; for (int count; (count = in.read(buf)) != -1;) outputStream.write(buf, 0, count); } catch (Exception e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } catch (IOException ignore) { } } } try { return outputStream.toString(charset); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return outputStream.toString(); } } }