Results 1 to 3 of 3
  1. #1
    MALLEK_AMIR is offline Member
    Join Date
    Apr 2015
    Rep Power

    Unhappy Loading File From “res” Folder That Contains byte array

    Am trying to load a .dat file that contains byte array of an image it seems like the "pathname" only accepts a defined path like "C:\\workspace\\Test\\res\\Image.dat" but i want it to load the file directly from res folder without any specification like /res/Image.dat or /res/graphics/Image.dat to prevent if the user change the application directory it will result a NoSuchFileException
    Java Code:
    public class Imageloader {
    public BufferedImage load(String pathname) throws IOException{
        Path path = Paths.get(pathname);
        byte[] data = Files.readAllBytes(path);
        InputStream in = new ByteArrayInputStream(data);
        BufferedImage bImageFromConvert =;
    return bImageFromConvert;
    looking forward for an answer and thanks.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Loading File From “res” Folder That Contains byte array

    You would have to either search from a root directory, looking for the file or you could prompt for the file. Even the most sophisticated programs usually require the user to specify certain file locations. You could also use an instance of JFileChooser to help the user specify the file. In that case, the name could be anything.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Loading File From “res” Folder That Contains byte array

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 5
    Last Post: 09-09-2014, 07:52 AM
  2. Compare byte array of two file mp3
    By kienkun1990 in forum Advanced Java
    Replies: 1
    Last Post: 09-16-2012, 08:20 AM
  3. Replies: 1
    Last Post: 10-21-2011, 11:55 AM
  4. converting byte array to bmp file
    By Moorkh in forum New To Java
    Replies: 2
    Last Post: 09-07-2010, 02:58 PM
  5. Reading/Writing a File using byte array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-16-2008, 10:41 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts