In the project resource files, I have a default image default_image.png. I need to go to him and translate it into an array of bytes.
Image image = new Image("/icons/default_image.png");
URL defaultImageFile = this.getClass().getResource("/icons/default_image.png");
byte[] array = Files.readAllBytes(Paths.get(defaultImageFile.getPath()));
I can take it to the URL as an image, but I can not as a file. How can I refer to this file as an image by URL?
new javax.swing.ImageIcon(getClass().getResource("/icons/default_image.png")), alternatively the MethodgetResourceAsStreamThen use stackoverflow.com/questions/1264709/… . What is your overall goal, why do you want to have bytes? How do you want to use the image?String imageAsString = Base64.getEncoder().encodeToString(array);