Nathan,
It's ugly to do it.
You can either bypass security (which I do) so that you can read a file
from an applet. Or you can use ugly code like:
URL iniURL = new URL(codebase, "our.ini");
URLConnection conn = iniURL.openConnection();
conn.connect();
BufferedReader br = new BufferedReader(new
InputStreamReader(conn.getInputStream()));
Beware... URLConnections don't let you write to them (normally). You can
only read.
- John Wright
Starfire Research
Nathan Bower wrote:
>
> Thanks for the reply.
>
> I am actually using something similar to this now - except that I pass the
> URL as a parameter rather than using global variables.
>
> The problem that arises is that I have to turn the url into a string so that
> I can use it in a FILE declaration (to open a datafile), and this does not
> seem to work.
>
> What mechanisms for opening files should be used when using URLs instead of
> Strings?
>
> Thanks
>
> Nathan
> ----- Original Message -----
> From: "Bob Dengle" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, July 06, 2001 11:17 PM
> Subject: Re: [JAVA3D] appletizing
>
> > Hi
> >
> > I think that you can use Applet.getCodeBase(), which will return a URL for
> > the location of the applet. Then, you can add the rest of the URL onto
> that
> > and use Applet.getImage(). For example:
> >
> > URL u = new URL(getCodeBase() + "/img.jpg");
> >
> > You can only call this from applet methods such as init(). The trick here
> is
> > to have a global URL variable. If you run as an applet, use the above line
> > of code to place the correct URL into your global variable. If you are
> > running it as an application, you should also assign the URL in a method
> > that isn't called by the applet, i.e. the main() method. When you are
> ready
> > to actually retrieve your image(maybe in a getTexture() method), you use
> the
> > global URL.
> >
> > B.D.
> >
> > >From: Nathan Bower <[EMAIL PROTECTED]>
> > >Reply-To: Discussion list for Java 3D API <[EMAIL PROTECTED]>
> > >To: [EMAIL PROTECTED]
> > >Subject: [JAVA3D] appletizing
> > >Date: Fri, 6 Jul 2001 21:22:15 +0100
> > >
> > >Hello guys, and gals,
> > >
> > >An appletizing problem (yum) for you here.
> > >
> > >Ive been turning my java3d standalone program into an applet for erm
> about
> > >a week now. Ive had a few tricky problems and this one I think somone
> else
> > >would have experienced before.
> > >
> > >In accessing a file (.jpg texture) I am using FILE and a string which
> > >consists of
> > >String filename = String.valueOf(tile.toExternalForm ()); // + more path
> &
> > >filename info.
> > >This results in trying to access a file from a location such as
> > >http://www.bhaldebla.com/images/1.jpg
> > >
> > >However - it dosent work.
> > >
> > >Q1. Has anyone else had a similar problem to this?
> > >Q2. What (generally) would be the method of accessing required data files
> > >from applets - retaining the ability to run as stand alone!
> > >
> > >
> > >Thanking you,
> > >
> > >Nathan
> > >
> > >
> > >PS. ARgggg!
> > >
> > >
> >
> > _________________________________________________________________
> > Get your FREE download of MSN Explorer at http://explorer.msn.com
> >
> >
> ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff JAVA3D-INTEREST". For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".