How Do I change a URL file location on my webspace for the same file on my Desktop - for a road trip.

beavoid used Ask the Experts™

On my road trip, in the car, I want to work on my invulnerable chess engine, (I'll move it from my PC to my Macbook)
but my chess piece .png files are on my web-space.

How can I change a URL object to be a local file, instead?

Passing the file's location into the URL constructor doesn't work, like some pages suggested.
What actually works, without deprecated solutions?

I have working..
URL url = new URL(" http://mydomain/graphicsFile.png");
pieceImages[0] = tk.createImage(url);

Open in new window

How do I do the same with a local file on a MacBook?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
CPColinSenior Java Architect

If that's java.awt.Toolkit you're using, there's an overload of the createImage() method that takes a string filename. Barring that, you might be able to use a URL if you start it with file://, instead of http://.
Top Expert 2016
Top Expert 2016


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial