Skip to main content



      Home
Home » Newcomers » Newcomers » How to open text file in eclipse (read it programmatically)?
How to open text file in eclipse (read it programmatically)? [message #90547] Fri, 29 July 2005 14:46 Go to next message
Eclipse UserFriend
Originally posted by: morphobit.freakmail.de

Hi everybody,
I'm trying to open a simple text file in eclipse in order to create a
String out of the file content and I'm not getting it to work.

I tried the following:

String textFile = "testproject/test.txt"
IPath textFileIPath = new Path ( textFileFile );
String textFileLocation =
ResourcesPlugin.getWorkspace().getRoot().findMember( textFileIPath
).getLocation().toString();
URI queryFileURI = URI.createFileURI( textFileLocation );
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.createResource( textFileURI );
resource.load( Collections.EMPTY_MAP );

Any help is appreciated!

Thanks,
Hans
Re: How to open text file in eclipse (read it programmatically)? [message #90932 is a reply to message #90547] Sun, 31 July 2005 10:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: seanmc42.hotmail.com

Just use File->Open File...

Hans Meier wrote:
> Hi everybody,
> I'm trying to open a simple text file in eclipse in order to create a
> String out of the file content and I'm not getting it to work.
>
> I tried the following:
>
> String textFile = "testproject/test.txt"
> IPath textFileIPath = new Path ( textFileFile );
> String textFileLocation =
> ResourcesPlugin.getWorkspace().getRoot().findMember( textFileIPath
> ).getLocation().toString();
> URI queryFileURI = URI.createFileURI( textFileLocation );
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource = resourceSet.createResource( textFileURI );
> resource.load( Collections.EMPTY_MAP );
>
> Any help is appreciated!
>
> Thanks,
> Hans
Re: How to open text file in eclipse (read it programmatically)? [message #91085 is a reply to message #90547] Sun, 31 July 2005 18:51 Go to previous message
Eclipse UserFriend
Hello Hans,
Shouldn't your second line read:
IPath textFileIPath = new Path ( textFile );
i.e. not textFileFile

Hope that helps.


Hans Meier wrote:
> Hi everybody,
> I'm trying to open a simple text file in eclipse in order to create a
> String out of the file content and I'm not getting it to work.
>
> I tried the following:
>
> String textFile = "testproject/test.txt"
> IPath textFileIPath = new Path ( textFileFile );
> String textFileLocation =
> ResourcesPlugin.getWorkspace().getRoot().findMember( textFileIPath
> ).getLocation().toString();
> URI queryFileURI = URI.createFileURI( textFileLocation );
> ResourceSet resourceSet = new ResourceSetImpl();
> Resource resource = resourceSet.createResource( textFileURI );
> resource.load( Collections.EMPTY_MAP );
>
> Any help is appreciated!
>
> Thanks,
> Hans
Previous Topic:Where to store icons etc & how to deploy them (Java Application)
Next Topic:How To Deploy Images ETc
Goto Forum:
  


Current Time: Sat May 31 09:33:49 EDT 2025

Powered by FUDForum. Page generated in 0.08585 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top