Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: access denied IOException when trying to read mp3 file on C drive

  1. #1
    Junior Member
    Join Date
    Aug 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default access denied IOException when trying to read mp3 file on C drive

    greetings to all,

    I am attempting to access a mp3 folder on my c drive. however I am recieving an IO exception stating that the file cannot be accessed. I have researched similar issues but cannot find a salution to my own one. what could i be doing wrong? heres my class:

    would greatly appreciate any replies

    //import java io and utilties packages
    //GO OVER CONSTRUCTOR METHODS
    import java.io.*;
    import java.util.*;
     
    //mp3 folder class
    class FolderMP3s
    {
        //constructor to set up objects
        FolderMP3s()
        {
            try
            {
                //file object
                File folder = new File("C:\\Users\\namso1902\\Cool Devices");
                //input and output stream objects
                FileInputStream inStream = new FileInputStream(folder);
                //file array
                File[] songs = new File[3];
                songs = folder.listFiles();
                //skip everything except last 128 bytes
                int size;
                //array to hold 128 bytes and in string format
                byte[] last128 = new byte[128];
                String id3;
                String tag; 
                //skip through each file
                for (int i = 0; i < 3; i++)
                {
                    size = (int) songs[i].length();
                    inStream.skip(size - 128);
                    inStream.read(last128);
                    id3 = new String(last128);
                    tag = id3.substring(0, 3);
                    //check tag of each file in folder
                    //change titles
                    if (tag.equals("TAG"))
                    {
                        System.out.println("tag: " + tag);
                    }
                }
     
            }
            //IOException is superclass of all IO exceptions
            catch (IOException ioe)
            {
                //display exception message
                System.out.println("File error details: " + ioe.getMessage());
            }
        }
     
        //main method
        public static void main(String[] arguements)
        {
            FolderMP3s mp3s = new FolderMP3s();
        }
    }


  2. #2
    Junior Member
    Join Date
    Aug 2013
    Posts
    19
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Default Re: access denied IOException when trying to read mp3 file on C drive

    What is the I/O exception you are getting? Can you please provide a stack trace?

  3. #3
    Member
    Join Date
    Jul 2013
    Posts
    219
    Thanks
    0
    Thanked 18 Times in 17 Posts

    Default Re: access denied IOException when trying to read mp3 file on C drive

    Hello.
    Based on the title of your post I guess you do not have privileges to access the file which you want to read.

    Syed.

Similar Threads

  1. Replies: 1
    Last Post: April 26th, 2013, 02:38 AM
  2. [SOLVED] Access Denied!
    By ajayajayaj in forum What's Wrong With My Code?
    Replies: 54
    Last Post: February 27th, 2013, 06:03 PM
  3. Read Permission Problem -Access Denied
    By ocean1991 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: December 28th, 2012, 09:38 AM
  4. [SOLVED] Access Denied when extracting zip file.
    By techwiz24 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 18th, 2011, 06:50 PM
  5. access denied (java.io.FilePermission "report.jrxml" read)
    By banny7 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: November 3rd, 2011, 06:02 AM