IWorkbenchPart workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); IFile file = (IFile) workbenchPart.getSite().getPage().getActiveEditor().getEditorInput().getAdapter(IFile.class); if (file == null) throw new FileNotFoundException(); String content = IOUtils.toString(file.getContents(), file.getCharset());
public InputStream getContents() throws CoreException { if (this.resource instanceof IFile) return ((IFile) this.resource).getContents(); return null; }
public InputStream getContents() throws CoreException { if (this.resource instanceof IFile) return ((IFile) this.resource).getContents(); return null; }
public InputStream getContents() throws CoreException { if (this.resource instanceof IFile) return ((IFile) this.resource).getContents(); return null; }
protected void loadBuildProperties(IFile buildPropertiesFile, Properties result) throws CoreException, IOException { InputStream buildPropertiesContents = buildPropertiesFile.getContents(true); result.load(buildPropertiesContents); buildPropertiesContents.close(); }
public static boolean fileIsEmpty(IFile file) throws IOException, CoreException { InputStream contents = null; try { contents = file.getContents(); return contents.read() == -1; } finally { if (contents != null) contents.close(); } }
private Manifest createSuppliedManifest(JarPackageData jarPackage) throws CoreException, IOException { Manifest manifest; // No need to use buffer here because Manifest(...) does InputStream stream= jarPackage.getManifestFile().getContents(false); try { manifest= new Manifest(stream); } finally { if (stream != null) stream.close(); } return manifest; }
private boolean isAxisServletExisted(IFile file, IProgressMonitor monitor) throws CoreException, ParserConfigurationException, SAXException, IOException { InputStream inputStream = file.getContents(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); SAXParser parser = factory.newSAXParser(); AxisServletSaxHandler handler = new AxisServletSaxHandler(); parser.parse(inputStream, handler); inputStream.close(); return handler.isThereAxisServlet(); }
protected void parseInput(IFile file) { Properties props = new Properties(); try (InputStream io = file.getContents()) { props.load(io); } catch (Exception e) { SdkLog.warning("could not open stream to read NLS file '{}'.", file.getFullPath(), e); } m_nlsTypeName = props.getProperty(MANIFEST_CLASS); }
public static ClassFileReader newClassFileReader(IResource resource) throws CoreException, ClassFormatException, IOException { InputStream in = null; try { in = ((IFile) resource).getContents(true); return ClassFileReader.read(in, resource.getFullPath().toString()); } finally { if (in != null) in.close(); } }
public static ClassFileReader newClassFileReader(IResource resource) throws CoreException, ClassFormatException, IOException { InputStream in = null; try { in = ((IFile) resource).getContents(true); return ClassFileReader.read(in, resource.getFullPath().toString()); } finally { if (in != null) in.close(); } }
public static ClassFileReader newClassFileReader(IResource resource) throws CoreException, ClassFormatException, IOException { InputStream in = null; try { in = ((IFile) resource).getContents(true); return ClassFileReader.read(in, resource.getFullPath().toString()); } finally { if (in != null) in.close(); } }
public void set(IFile iFile) throws CoreException { resetAll(); InputStream inputStream = iFile.getContents(true); InputStream resettableStream = new BufferedInputStream(inputStream, MAX_BUF_SIZE); resettableStream.mark(MAX_MARK_SIZE); set(resettableStream); }
public void load() throws CoreException { if (fFile.exists()) { InputStream stream = null; try { stream = new BufferedInputStream(fFile.getContents(true)); load(stream, false); } catch (CoreException e) { } } }
public Manifest getManifest() { IFile file = getProject().getFile(new Path(TypeConstants.META_INF_MANIFEST_MF)); if (file.exists()) { try (InputStream contents = file.getContents()) { return new Manifest(contents); } catch (IOException | CoreException e) { // unusable manifest } } return null; }
/** * @since 2.4 */ public InputStream readBinaryFile(String fileName, String outputCfgName) throws RuntimeIOException { try { IFile file = getFile(fileName, outputCfgName); return file.getContents(); } catch (CoreException e) { throw new RuntimeIOException(e); } }
public Manifest getManifest() { IFile file = getProject().getFile(new Path(TypeConstants.META_INF_MANIFEST_MF)); if (file.exists()) { try (InputStream contents = file.getContents()) { return new Manifest(contents); } catch (IOException | CoreException e) { // unusable manifest } } return null; }
public static String getContent(IFile file) throws CoreException { if (file == null) { return null; } String content; try { content = IOUtil.toString(file.getContents()); } catch (IOException e) { throw new CoreException(StatusFactory.newErrorStatus("Can not get " + file.getRawLocation() + " content", e)); } return content; }
private InputStream createInputStream(IFile propertiesFile) throws CoreException { ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); if (manager != null) { ITextFileBuffer buffer= manager.getTextFileBuffer(propertiesFile.getFullPath(), LocationKind.IFILE); if (buffer != null) { return new ByteArrayInputStream(buffer.getDocument().get().getBytes()); } } return propertiesFile.getContents(); }
private InputStream createInputStream(IFile propertiesFile) throws CoreException { ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); if (manager != null) { ITextFileBuffer buffer= manager.getTextFileBuffer(propertiesFile.getFullPath(), LocationKind.IFILE); if (buffer != null) { return new ByteArrayInputStream(buffer.getDocument().get().getBytes()); } } return propertiesFile.getContents(); }