本文整理匯總了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();
}
}
示例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();
}
}
示例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);
}
}
示例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 + "'");
}
}
示例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 );
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}