Avatar of James Hancock
James Hancock
Flag for United States of America asked on

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


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?

Game ProgrammingJava

Avatar of undefined
Last Comment

8/22/2022 - Mon

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://.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.