當前位置: 首頁>>代碼示例>>Java>>正文


Java FileLocator.openStream方法代碼示例

本文整理匯總了Java中org.eclipse.core.runtime.FileLocator.openStream方法的典型用法代碼示例。如果您正苦於以下問題:Java FileLocator.openStream方法的具體用法?Java FileLocator.openStream怎麽用?Java FileLocator.openStream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.runtime.FileLocator的用法示例。


在下文中一共展示了FileLocator.openStream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadAndroidCallbacks

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public void loadAndroidCallbacks() throws IOException {
	this.androidCallbacks = new HashSet<String>();
	String line;
	InputStream is = null;
	BufferedReader br = null;

	try {
		is = FileLocator.openStream(Activator.getDefault().getBundle(), new Path(Config.callbacks), false);
		br = new BufferedReader(new InputStreamReader(is));
		while ((line = br.readLine()) != null)
			androidCallbacks.add(line);
	} finally {
		if (br != null)
			br.close();
		if (is != null)
			is.close();
	}
}
 
開發者ID:secure-software-engineering,項目名稱:cheetah,代碼行數:19,代碼來源:Activator.java

示例2: readFile

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private void readFile(String fileName) throws IOException {
	String line;
	this.data = new ArrayList<String>();
	InputStream is = null;
	BufferedReader br = null;

	try {
		is = FileLocator.openStream(Activator.getDefault().getBundle(), new Path(fileName), false);
		br = new BufferedReader(new InputStreamReader(is));
		while ((line = br.readLine()) != null)
			this.data.add(line);
	} finally {
		if (br != null)
			br.close();
		if (is != null)
			is.close();
	}
}
 
開發者ID:secure-software-engineering,項目名稱:cheetah,代碼行數:19,代碼來源:PermissionMethodParserJIT.java

示例3: extractJar

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
protected static void extractJar(
    Plugin plugin, String pathInPluginJar, String pathInStateLocation)
    throws IOException {
  IPath pluginStateLocation = plugin.getStateLocation();
  File fileInStateLocation = pluginStateLocation.append(
      pathInStateLocation).toFile();
  fileInStateLocation.delete();

  FileOutputStream os = null;
  InputStream is = FileLocator.openStream(
      plugin.getBundle(), new Path(pathInPluginJar), false);

  try {
    os = new FileOutputStream(fileInStateLocation);

    byte[] buf = new byte[2048];
    int bytesRead = 0;
    while ((bytesRead = is.read(buf)) != -1) {
      os.write(buf, 0, bytesRead);
    }
  } finally {
    closeStreams(is, os);
  }
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:25,代碼來源:AbstractGwtPlugin.java

示例4: widgetSelected

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
public void widgetSelected(SelectionEvent e) {
	Shell parentShell = e.display.getActiveShell();
	FileDialog fd = new FileDialog(parentShell, SWT.SAVE);
	fd.setFilterExtensions(new String[]{"*.jar", "*.*"});
	fd.setFilterIndex(0);
	fd.setFileName("BrainfuckInterpreter.jar");
	fd.setOverwrite(true);
	String selectedFile = fd.open();
	if (selectedFile == null) {
		return;
	}
	java.nio.file.Path savePath = Paths.get(selectedFile);
	try {
		InputStream jarStream = FileLocator.openStream(BfActivator.getDefault().getBundle(), new Path("/lib/interpreter.jar"), false);
		Files.copy(jarStream, savePath, StandardCopyOption.REPLACE_EXISTING);
		jarStream.close();
		MessageDialog.openInformation(parentShell, "Saved", "'" + savePath.getFileName() + "' saved successfully");
	} 
	catch (IOException ex) {
		BfActivator.getDefault().logError("Interpreter Jar File could not be saved", ex);
		MessageDialog.openError(parentShell, "File not saved", "Error on saving '" + selectedFile + "'");
	}
}
 
開發者ID:RichardBirenheide,項目名稱:brainfuck,代碼行數:25,代碼來源:BfMainPreferencePage.java

示例5: createInputSource

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
protected InputStream createInputSource () throws Exception
{
    Type type = this.page.getTypeSelection ();
    if ( type == null )
    {
        type = Type.EMPTY;
    }
    return FileLocator.openStream ( Activator.getDefault ().getBundle (), new Path ( String.format ( "templates/%s", type.getResourceName () ) ), true );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:11,代碼來源:JavaScriptPipelineWizard.java

示例6: createExample

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
protected void createExample(IProject project) {
	Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
	try (InputStream stream = FileLocator.openStream(bundle, new Path("examples/greeter.sol"), false)) {
		IFile file = project.getFile("greeter.sol");
		file.create(stream, true, null);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:Yakindu,項目名稱:solidity-ide,代碼行數:10,代碼來源:KickStartNewProjectAction.java

示例7: getBundleResourceStream

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public static InputStream getBundleResourceStream( String pluginID, String uri){
   try {
      if (Utils.isIDE()) {
         return FileLocator.openStream(Platform.getBundle(pluginID), new Path(uri), false);
      } else {
         return new FileInputStream(uri);
      }
   } catch (Throwable e) {
      ExceptionHandler.handle(e);
   }
   return null;
}
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:13,代碼來源:ResourceUtils.java

示例8: getBundleResourceStream2

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public static InputStream getBundleResourceStream2( String pluginID, String uri) throws IOException{
   if (Utils.isIDE()) {
      return FileLocator.openStream(Platform.getBundle(pluginID), new Path(uri), false);
   } else {
      return new FileInputStream(uri);
   }
}
 
開發者ID:nextinterfaces,項目名稱:http4e,代碼行數:8,代碼來源:ResourceUtils.java

示例9: loadResource

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/** {@inheritDoc}} */
@Override
public <T> T loadResource(final Class<?> bundleClazz, final Class<T> resourceTypeclazz, final String pathToFile)
		throws IOException {
	final Bundle bundle = FrameworkUtil.getBundle(bundleClazz);
	final InputStream stream = FileLocator.openStream(bundle, new Path(pathToFile), false);

	if (resourceTypeclazz.isInstance(InputStream.class)) {
		return resourceTypeclazz.cast(stream);
	}

	return null;
}
 
開發者ID:amitjoy,項目名稱:Kura-MQTT-Client-Utility,代碼行數:14,代碼來源:BundleResourceLoaderImpl.java

示例10: copyFileFromBundle

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
protected void copyFileFromBundle(Bundle bundle, IPath sourcePath, IPath targetPath) {
	try {
		InputStream is = FileLocator.openStream(bundle, sourcePath, false);
		createFile(targetPath, is);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:9,代碼來源:GTestHelper.java

示例11: readSourceFile

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
private CharSequence readSourceFile(String sourceFile) throws IOException {
		Bundle bundle = getTestBundle();
//		System.out.println("[GTestRunner] Loaded bundle " + bundle.getSymbolicName());
		InputStream is = FileLocator.openStream(bundle, new Path(sourceFile), false);
		Reader reader = new InputStreamReader(is);
		char[] buffer = new char[4096];
		StringBuilder sb = new StringBuilder(buffer.length);
		int count;
		while ((count = reader.read(buffer)) != -1) {
			sb.append(buffer, 0, count);
		}
		reader.close();
		is.close();
		return sb;
	}
 
開發者ID:Yakindu,項目名稱:statecharts,代碼行數:16,代碼來源:GTestRunner.java

示例12: getResourceAsStream

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
public static InputStream getResourceAsStream(IPath path) {
    try {
        return FileLocator.openStream(plugin.getBundle(), path, true);
    } catch (IOException e) {
        log(e);
    }
    return null;
}
 
開發者ID:anb0s,項目名稱:eclox,代碼行數:9,代碼來源:Plugin.java

示例13: getInitialContents

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
protected InputStream getInitialContents() {
	try {
		return FileLocator.openStream(BfActivator.getDefault().getBundle(), new Path(TEMPLATE_PATH), false);
	} 
	catch (IOException ex) {
		BfActivator.getDefault().logError("Template for new file could not be read", ex);
	}
	return null;
}
 
開發者ID:RichardBirenheide,項目名稱:brainfuck,代碼行數:11,代碼來源:NewBfFileCreationWizardPage.java

示例14: getPluginFileStream

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
/**
 * Gets an input stream for a file in the plug-in's jar file.
 * @param relativePath The path to the file
 * @return An input stream to the file, or null if it could not be opened.
 */
public InputStream getPluginFileStream( String relativePath ) 
{
   try {
      Bundle bundle = Platform.getBundle( Ids.PLUGIN );
      Path path = new Path( relativePath );
      
      return FileLocator.openStream( bundle, path, false );        
   } catch( IOException e ) {      
      ZDebug.printStackTrace( e, "Trying to open file in bundle failed - ", relativePath );
   }
   return null;
}
 
開發者ID:brocade,項目名稱:vTM-eclipse,代碼行數:18,代碼來源:ZXTMPlugin.java

示例15: getSchemaStream

import org.eclipse.core.runtime.FileLocator; //導入方法依賴的package包/類
@Override
protected InputStream getSchemaStream()
{
	try
	{
		return FileLocator.openStream(CSSCorePlugin.getDefault().getBundle(),
				Path.fromPortableString(METADATA_SCHEMA_XML), false);
	}
	catch (IOException e)
	{
		return this.getClass().getResourceAsStream(METADATA_SCHEMA_XML);
	}
}
 
開發者ID:apicloudcom,項目名稱:APICloud-Studio,代碼行數:14,代碼來源:CSSMetadataReader.java


注:本文中的org.eclipse.core.runtime.FileLocator.openStream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。