Hi Raghu,

The GWT compiler complains because it doesn't support the full range
of Java classes present in your run of the mill JRE. The reason for
this can be found in asking the question; "What does the GWT compiler
produce as output?". Answering this question yields a far more
pertinent question; "Where does the resulting JavaScript execute?".
The answer of course is the client's browser.

Knowing this, it's fairly safe to assume that if we can achieve the
same thing using pure JavaScript in the browser (i.e. we could port
our Java code to JavaScript) then it's possible with GWT. Given that a
browser has no native mechanism that supports file IO (besides perhaps
the file input tag) then it makes sense that there would be no File
class in GWT. The GWT developers know this and to this extent they've
exposed a great deal of base Java classes (primarily the java.lang
package) as native peers. This is relatively straight-forward for
things like String which can easily be wrapped with a Java class that
provides the expected API yet are manipulated underneath the covers
using standard JS string functions.

If you're ever unsure as to whether or not a native Java class is
supported in GWT you can always refer back to the JRE emulation
reference here: 
http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=google-web-toolkit-doc-1-5&t=RefJreEmulation

Regards,

Dave

On Mar 4, 4:07 am, Lothar Kimmeringer <j...@kimmeringer.de> wrote:
> raghu prashanth k b schrieb:
>
> > Hi...I am new to GWT and i'm trying to develop a small
> > application...but here i need to open a directory and count the no.of
> > files in it.......I'm doing it as follows:
>
> >                 File dir = new File(file);
> >            String[] pages = dir.list();
> >            int count = pages.length;
>
> If you do that on the client-side of your application, you should
> ask yourself, how you would do that with Javascript. If you can
> come up with an answer (you can't without the use of signed applets
> or other tweaks), the compiler can't either.
>
> This is a question that has been answered so many times already
> that searching for the error-message, in this group should bring
> up a lot of results, including ways how to solve your problem
> (that is dependent if you really want to have a file-list of the
> files residing on the client-side or if you want ot list files
> residing on the server-side).
>
> Regards, Lothar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to