URL

create a data URI from an URL

Recently I needed for my mapjfx project to convert an image, where I had the URL of, to a base64 encoded data-URI. The following code shows how to do the conversion (Java 8 code): /* * (c) 2015 P.J. Meisch (pj.meisch@sothawo.com). */ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.net.*; import java.util.Base64; import java.util.logging.Level; import java.util.logging.Logger; public class Test { private static Logger logger = Logger.getAnonymousLogger(); public static URI getDataURIForURL(URL url) { URI dataUri = null; if (null !