Problem with reading PNG metadata due to unicode strings

Being new to the XMP SDK I have problems trying to dump the XMP data from a .png file because the data contains UTF-8 data.
I have searched the forum for answers, but the answers I found do not help.
The answer I found was to replace std::string with std::wstring. but that causes problems with the compile - btw, I am using MSVC 2010 C++ Express
and XMP SDK-CC201306
Changing the std:: line to:
#define TXMP_STRING_TYPE std::wstring
and all string definitions in my code to wstring, gives me a bunch of compile errors, such as:
f:\pkg\c++\xmp-toolkit-sdk-cc201306\public\include\client-glue/TXMPMeta.incl_cpp(74): error C2664: 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::assign(const _Elem *,unsigned int)' : cannot convert parameter 1 from 'XMP_StringPtr' to 'const wchar_t *'
1>          with
1>          [
1>              _Elem=wchar_t,
1>              _Traits=std::char_traits<wchar_t>,
1>              _Ax=std::allocator<wchar_t>
1>          ]
1>          Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
1>          f:\pkg\c++\xmp-toolkit-sdk-cc201306\public\include\client-glue/TXMPMeta.incl_cpp(72) : while compiling class template member function 'void TXMPMeta<tStringObj>::SetClientString(void *,XMP_StringPtr,XMP_StringLen)'
1>          with
1>          [
1>              tStringObj=std::wstring
1>          ]
1>          f:\pkg\c++\XMP-Toolkit-SDK-cc201306\public\include\XMP.incl_cpp(55) : see reference to class template instantiation 'TXMPMeta<tStringObj>' being compiled
1>          with
1>          [
1>              tStringObj=std::wstring
1>          ]
Any help or pointers will be most welcome.
TIA,
DayWalker

OK, I now understand the point you were driving at.
To check out this idea, I have modified the code in the routine which dumps the output from the callback to a file as follows:
(Though if you were to dump the file using the std:: stream - .i.e. using the utility as supplied, you should see the same problem - it is not at all dependent on my using the wxWidgets toolkit)
XMP_Status DumpXMPToFile(void * WXUNUSED(refCon), XMP_StringPtr buffer, XMP_StringLen bufferSize )
    XMP_Status status = 0;
    wxString wsT;
    try
    wxString wsText( buffer, wxConvUTF8 );
    if( g_wfDumpFile.IsOpened() )
      wsT.Printf( _T("<%s> size(%d)"), wsText, bufferSize );
      g_wfDumpFile.SeekEnd();
      g_wfDumpFile.Write( wsT, wsT.Length() );
    else
      return -1;
    catch(XMP_Error & e)
The output for the one line in question:
<Iptc4xmpCore:CiAdrExtadr> size(24)< = "> size(4)<Leo-Saurer-Straße> size(15)<> size(1)<C3> size(2)<> size(1)<9F> size(2)<>> size(1)<e> size(1)<"> size(1)<
> size(1)<   > size(3)<   > size(3)<   > size(3)
The hex contents of the buffer I get in the callback is
0x003908D0  4c 65 6f 2d 53 61 75 72 65 72 2d 53 74 72 61 c3 9f 65 00 cd cd cd cd  Leo-Saurer-Straße.ÍÍÍÍ
0x003908E7  cd cd cd cd cd cd cd cd cd fd fd fd fd ab ab ab ab ab ab ab ab ee fe  ÍÍÍÍÍÍÍÍÍýýýý««««««««îþ
As you can see, my conversion routines takes all the buffer contains and converts it to the appropriate UTF-8 string, even though the count passed to me is short and represents only the count up to the first non-ASCII character and all of the subsequent strings  - interpreted as hex values by the caller of the call back would not give me the correct characters, athough they are passed to me for display.
The two fragments of one byte length are the ones I could not find in the actual output.
The call stack at that point:
>
wxMeta.exe!DumpXMPToFile(void * __formal, const char * buffer, unsigned long bufferSize)  Line 110
C++
wxMeta.exe!TextOutputProcWrapper(void * refCon, const char * buffer, unsigned long bufferSize)  Line 60 + 0x18 bytes
C++
wxMeta.exe!DumpClearString(const std::basic_string<char,std::char_traits<char>,std::allocator<char> > & value, long (void *, const char *, unsigned long)* outProc, void * refCon)  Line 409 + 0x1c bytes
C++
wxMeta.exe!DumpPropertyTree(const XMP_Node * currNode, int indent, unsigned int itemIndex, long (void *, const char *, unsigned long)* outProc, void * refCon)  Line 161 + 0x14 bytes
C++
wxMeta.exe!DumpPropertyTree(const XMP_Node * currNode, int indent, unsigned int itemIndex, long (void *, const char *, unsigned long)* outProc, void * refCon)  Line 222 + 0x1f bytes
C++
wxMeta.exe!XMPMeta::DumpObject(long (void *, const char *, unsigned long)* outProc, void * refCon)  Line 1100 + 0x23 bytes
C++
wxMeta.exe!WXMPMeta_DumpObject_1(__XMPMeta__ * xmpObjRef, long (void *, const char *, unsigned long)* outProc, void * refCon, WXMP_Result * wResult)  Line 968
C++
wxMeta.exe!TXMPMeta<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >::DumpObject(long (void *, const char *, unsigned long)* outProc, void * refCon)  Line 833 + 0x21 bytes
C++
wxMeta.exe!MyFrame::DisplayMetaData(wxString & wsrFilePathAndName)  Line 484
C++
Hoping this will help resolve the issue :-)

Similar Messages

  • Problem with CFimage / PNG images

    I have a problem saving PNG images from another server, for example itunes, some work, some don't
    The following image will open fine in my browser ->
    http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa36 7/icon.png
    This is the error I am receiving:
    An exception occurred while trying to read the image.
    javax.imageio.IIOException: Error reading PNG metadata
    Code:
    <cfimage source="http://a576.phobos.apple.com/us/r30/Purple/v4/de/60/bb/de60bb7f-8995-4007-cfec-1b0a472fa36 7/icon.png" overwrite="true"  destination="#filepath#/9999.png"
        action = "write">
    I believe some images have malformed/incorrect headers. I'm guessing this is a CF issue (I use CF8), because it loads fine in a browser.
    Anybody have a solution to this? Maybe an alternative way to retrieve the image? Custom tag?
    Thanks
    Mark

    I found the issue and solution. The problem was with the Java, the JVM had issues reading SOME PNG's from servers, but not all, there must be a newer way of encoding them that was not around when the version of java I had was created, or it's just a bug. I had an earlier version of 1.6 which is downloaded as version SE 6 from Oracle.
    As per some instructions by Ben Forta I tried an update of the JVM to version 7 (1.7.x),
    http://forta.com/blog/index.cfm/2013/3/3/Upgrading-ColdFusion-To-Java-7
    The update worked on my local dev machine which was CF8 with Win 7 64bit, and it actually fixed the CFIMAGE issue!
    However, when I did the same update, with the same java file on the same version of CF8, CF would no longer restart throwing an error that it could not find a file.
    Luckily I had a backup of the config file because I could not switch settings back any other way if CF would not start the administrator (Java also makes a .BAK anyway)
    I tried the first build of version 7, same problem, so I went to the very last version 6, build 45, it installed, and it also fixed the CFIMAGE crash!
    A couple of points for anybody else trying this
    Make sure you have a back up the config, in CF8 it's located here (different to the location in Bens instructions)
    Coldfusion8\runtime\bin\jvm.config
    Also note that the forward and backward slashes are different for the built in JVM that ships with CF and is set in the administrator, and the location you will specify
    Original location: C:/ColdFusion8/runtime/jre
    New location: C:\Program Files\Java\jre7\
    Here is the location to the Java file (
    Java SE Runtime Environment 6u45)
    Java Archive Downloads - Java SE 6
    Took me days to get to the bottom of this, but the fix actually takes just a few simple steps and a few minutes, of course
    Mark

  • What does this statement mean: "There is a problem with your authentication, possibly due to inactivity. For your safety, you have been logged out and must sign in again to continue?"

    I am able to make it to the site for about 2 seconds and then I am quickly logged off and the statement, "There is a problem with your authentication, possibly due to inactivity. For your safety, you have been logged out and must sign in again to continue."
    I don't have a clue as to the problem but since this is impacting my participation in these classes and ultimately could have a negative impact on my grade, I am more than a little concerned!

    Have you allowed this site to set cookies?

  • Problem with READ Statement in the field routine of the Transformation

    Hi,
    I have problem with read statement with binary search in the field routine of the transformation.
    read statement is working well when i was checked in the debugging mode, it's not working properly for the bulk load in the background. below are the steps i have implemented in my requirement.
    1. I selected the record from the lookuo DSO into one internal table for all entried in source_packeage.
    2.i have read same internal table in the field routine for each source_package entry and i am setting the flag for that field .
    Code in the start routine
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
         and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp <> 3.
    delete it_zcam where end_dt initial.
    sort it_zcam by surce accno.
    endif.
    field routine code:
    read table it_zcam with key source = source_package-source
                                                 accno  = source_package-accno
                                                 binary search
                                                 transportin no fields.
    if sy-subrc = 0.
    RESULT  = 'Y'.
    else.
    RESULT = 'N'.
    endif.
    this piece of code exist in the other model there its working fine.when comes to my code it's not working properly, but when i debug the transformation it's working fine for those accno.
    the problem is when i do full load the code is not working properly and populating the wrong value in the RESULT field.
    this field i am using in the report filter.
    please let me know if anybody has the soluton or reason for this strage behaviour.
    thanks,
    Rahim.

    i suppose the below is not the actual code. active table of dso would be /bic/azcam_o1100...
    1. is the key of zcam_o11 source and accno ?
    2. you need to get the sortout of if endif (see code below)
    select source accno end_dt acctp from zcam_o11
    into table it_zcam
    for all entries in source_package
    where source = source_package-source
    and accno = source_package-accno.
    if sy-subrc = 0.
    delete it_zcam where acctp 3.
    delete it_zcam where end_dt initial.
    endif.
    sort it_zcam by surce accno.
    field routine code:
    read table it_zcam with key source = source_package-source
    accno = source_package-accno
    binary search
    transportin no fields.
    if sy-subrc = 0.
    RESULT = 'Y'.
    else.
    RESULT = 'N'.
    endif.

  • Having problem with reading list in safari

    i am having problem with reading list in safari some time it work sometimes gets hang....

    Might be a cache issue ...
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following:
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.

  • I am facing a Problem with reading images from database

    Hi everybody..
    any help will be most appreciated, I am facing problem with reading images from database. I am pasting my code... 
                    string connect = "datasource = localhost; port = 3306; username = root; password = ;"; 
                    MySqlConnection conn = new MySqlConnection(connect); // creating connecting string
                    MySqlCommand sda = new MySqlCommand(@"select * from management.add_products ", conn); //creating query
                    MySqlDataReader reader; 
                    try
                        conn.Open(); // Opening Connection
                        reader = sda.ExecuteReader(); // Executing my Query..
                        while (reader.Read())
                            byte[] imgg = (byte[])(reader["Picture"]);
                            if (imgg == null)
                                pc1.Image = null;
                            else
                                MemoryStream mstream = new MemoryStream(imgg);
                                pc1.Image = System.Drawing.Image.FromStream(mstream);
    It says Parameter not Valid... i am reading all the images from database

    I agree with Viorel. You are getting the error because the format of the data is incorrect probably because the data was modify. It may not be the reading of the database the is incorrect, but the application that wrote the data into the database. You need
    to compare the imgg array data with the data before it was written to the database to see if the data matches.  I usually start by comparing the number of bytes which is easier to check then compare the actual to isolate which function is changing the
    byte count.
    An image is binary data.  The standard VS methods for reading and writing data (usually stream classes) default to ASCII encoding which will corrupt binary data.  The solution usually is to use UTF8 encoding instead of the default ascii encoding. 
    Ascii encoding with stream often aligns the data and adds extra null bytes to the end of the data which can produce these type errors.
    jdweng

  • Problem with reading config file

    Hello,
    I have problem with reading config file from the same dir as class is. Situation is:
    I have servlet which working with DB, and in confing file (config.pirms) are all info about connection (drivers, users, passw, etc.). Everything work fine if I hardcoded like:
    configFileName = "C:\\config.pirms";I need to avoid such hardcoding, I tryied to use:
    configFileName = Pirms.class.getClassLoader().getResourceAsStream ("/prj/config.pirms").toString();but it isn't work.
    My config file is in the same directory as Pirms.class (C:\apache-tomcat-5.5.17\webapps\ROOT\WEB-INF\classes\prj)
    Also I tryied BundledResources, it isn't work fo me also.
    Can anybody help me to solve this problem? with any examples or other stuff?
    Thanks in advance.
    Andrew

    Thanks, but I am getting error that "non-static method getServletConfig() cannot be referenced from a static context"
    Maybe is it possibility to use <init-param> into web.xml file like:
    <init-param>
      <param-name>configFile</param-name>
      <param-value>/prj/config.pirms</param-value>
    </init-param>If yes can anybody explain how to do that?
    I need to have that file for:
    FileReader readFile = new FileReader(configFile);Thanks in advance.

  • I am experiencing problems with my i phone due to sharing my daughters i tunes acoount. I have been told by apple to cancel my existing (shared) i tunes account and open a new one for my use only. How do I do this? Please help. RM

    I am experiencing on going problems with my i phone 4 due to me sharing an i tunes account with my daughter. I have been told by apple to cancel my existing (shared) i tunes account and open a new one for my use only. How do I do this? I cant find any links in i tunes to do this. mountfield

    No, it's done on the computer, it's just done on the web and not through iTunes. I guess you could do it on the iPhone, but it would be easier to do on the computer.
    Just go to the site linked above, then click on the big blue button and fill out the neccessary information.

  • Booklet printing problems with Reader XI (version 11.0.06)

    I created an 80 page 5.5" x 8.5" booklet using Word 2011 running under OSX 10.9.2 on a new 27" iMac.  I then "printed" it to a PDF file.  I then opened the PDF file in Reader XI and attempted to print it out using the "booklet" option as described at
    http://helpx.adobe.com/acrobat/kb/print-booklets-acrobat-reader.html#main1_Reader_and_Acro bat_X .
    I planned to manually duplex the booklet booklet since my HP Color Laserjet CP1518ni printer does not have automatic duplexing.  The first sign that something was wrong came when I selected "Back side only" from the Booklet Subset pop-up menu.  The numbers in the Sheets from boxes showed "Sheets from 1 to 10" when I obviously needed 20 sheets to print the booklet.  Repeated attempts to manually change it to "Sheets from 1 to 20" failed.  Each time I changed "10" to "20", it would flip back to "10" when I clicked the "Print" button.
    I set the Booklet Subset to print only the even pages and checked the "Reverse" box as I have done to successfuly print thousands of manually duplexed pages before.
    The printer only printed ten sheets.  The first sheet (what should be the booklet's centerfold) had page 40 on the left side as it should, but 42 on the right (it should have been 41).  The last of the ten sheets printed had page 4 on the left side (instead of the expected  2) and 78 on the right side (instead of the expected  79).  Even though these were obviously messed up, I went on to print the front side of these sheets, selecting "normal".  It printed Page 1 on the right side as expected, but printed page 79 (instead of the correct page 80) on the left.
    Folding the ten sheets into a booklet revealed the really bizarre nature of the printing snafu. Page 1 was, as expected, on the front.  Turning the first page open revealed pages 4 and 5.  Turning the second page revealed Pabes 8 (left) and 9 (right).  This pattern continued, printing two pages, then skipping two pages, right into the centerfold pages 40 (left) and 42 (right).  The first page turn after the centerfold revealed pages 43 (left) and 46 (right).  The next revealed 47 (left) and 50 (right).
    I am at a complete loss of how to determine where the printing process went afoul.  Printing the PDF file normally (one page per sheet one-sided) resulted in all pages being printed normally. 
    The really frustrating part of this entire experience is that I could find no place to report this "bug" to Adobe.  If anyone can help me solve this printing dilemma, or put me in touch with someone at Adobe who could help, it would be greatly appreciated.
    The booklet is due at the printer's tomorrow and the inability to print a proof is a real pain.  Hope the printer can print this file as a booklet.  I would be happy to send this file (125 Mb) to anyone who might help.

    I arrived here looking for a solution!  And while reading your post the penny dropped that I didn't have a serious problem.  I have a booklet of 112 pages and all I needed to do was re-order the pages as printed so that 1 is followed by a sheet with 2 on the under-face but same side and so on.  The pages had printed back to front and needed flipping.  But then I have a duplex printer and maybe that makes a difference.  Is it to do with your manual duplexing and the order that the second pass is presented to the printer.  As my duplex sheets effectively needed flipping over each one I'm wondering if you can solve your problem with a little experimentation and re-ordering before your second pass.

  • GUI_DOWNLOAD problems with CR+LF when transfering from unicode system

    Hi,
    I was successfuly used FM GUI_DOWNLOAD in a non-unicode systems for years. Lately I faced a challenge to rewrite my code for a unicode system. The configuration is:
    - SAP R/3 unicode system;
    - data to be downloaded at presentation server in a non-unicode codepage (cp 9504).
    I have successfuly used a GUI_DOWNLOAD-parameter CODEPAGE and the data is translated correctly when checking local file, but due to some reasons CRLF are replaced with '#' (which is default value of REPLACEMENT parameter of this function) - means at the end of each row as a result I have '##' instead of CRLF.
    My question is: how can I force correct behaviour of GUI_DOWNLOAD in order to get my output file at presentation server with CR+LF?
    Any help would be highly appreciated.
    Many thanks in advance.
    Regards,
    Ivaylo Mutafchiev
    SAP/ABAP consultant
    VBS Ltd.
    P.S. In order to find some other way to fix my problem I'm still playing with the instanciation of a CL_ABAP_CONV_OBJ and its methods create & convert, but without success for now - resulted strings are not as expected.

    Hi,
    in fact, I never placed CRLF in my lines before your suggestion. The rest was done by the FM 'GUI_DOWNLOAD'. It works fine even when I use unicode file as output - means I got my CRLF at the end of the record in MY OUTPUT FILE ONLY but not in my internal table - I never placed CR+LF in there.
    The problem occures when I tried to use GUI_DOWNLOAD with parameter CODEPAGE = '9504' (some non-unicode codepage), and the original data (my internal table) is in unicode. Then (in my opinion) this function doesn't translate the unicoded CR+LF into non-unicode ones (if thats possible at all, I can't be sure) and the result is '##' in the output file.
    I checked the value of CL_ABAP_CHAR_UTILITIES=>CR_LF by getting it in my variable - and it is '##'.
    Whet should I put into this class-attribute in order to get it working in this scenario? I have no idea...
    The attribute type is ABAP_CR_LF - which is char 2.
    What next?
    Thanks,
    Ivaylo

  • Problem with 'Edit Locally' command -- Due to IISProxy?

    Hi,
    We have a problem with 'Edit Locally' command since we are using Windows Authentication. Our architecture is:
    SAP EP 6.0 SP2 Patch 28 (Solaris)
    IIS Proxy (Windows 2003)
    The situation is:
    If we access to SAP Portal using old url (directly to Solaris) using form-based authentication we do not have any problem with 'edit locally' command.
    However, if we access to SAP Portal using IISProxy and Windows Authentication we get an 'Operation failed' error message.
         Java plug-in console shows the following message:
    cargar: clase com/sapportals/wcm/app/docapplet/DocApplet.class no encontrada.
    java.lang.ClassNotFoundException: com.sapportals.wcm.app.docapplet.DocApplet.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Where is the problem? Is due to authentication method? SAP Portal or IISProxy configuration?
    Thanks,

    Thanks for your comment,
    Now, we have tested with version 1.5.0_01 plugin version but the result is the same: 'Operation failed'
    This is a very important topic to solve before installing Windows Authentication in a productive environment.
    Has anybody any solution?
    Damiá

  • Problems with sending IDOC via RFC from Unicode to NonUnic

    Hello
    I have following problem, sending an IDOC via RFC from Unicode to Non Unicode System. IDoc is not sent with error: codepage of receiver system cant determined. receiver destination was: Message no. B1999
    I have tried different options in sm59, but it didnt help.
    Any ideas? The recipient system is rather old, version 4.0

    hey,
    I had a similar experience. I was interfacing between 4.6 (RFC), PI and ECC 6.0 (ABAP Proxy). When data was passed from ECC to 4.6, RFC received them incorrectly. So i had to send trimmed strings from ECC and receive them as strings in RFC (esp for CURR and QUAN fields). Also the receiver communication channel in PI (between PI and  RFC) had to be set as Non unicode. This helped a bit. But still I am getting 2 issues, truncation of values and some additional digits !! But the above changes resolved unwanted characters problem like "<" and "#". You can find a related post in my id. Hope this info helps..

  • Problem with the PNG file icon

    Hello. This is the first time I'm posting something here, so please be merciful. :) Yesterday I saw that the file icons of the PNG files are not the blue ones (like we all know them, after installing Photoshop CS3), but the default Windows (I'm using Windows XP SP3) icons. I mean like when I don't have a program to open a given file, that is how it looks like. But when I double click on the PNG file it opens right away, so in my eyes there is a problem, of some kind, with the ICO file itself. The strangest thing is that this ICO file is not missing, deleted or moved! This happened only with the PNG files. All other Photoshop related files are ok and have their respective icons. Can someone tell me how to change the PNG file icon, so I can choose manually the ICO file.

    @roshlioto This is a windows issue NOT Photoshops. So wrong place on the Internet.
    However, you right click on the shortcut/icon whatever, (in Windows) and choose the icon/app you wish to associate with a given file.

  • Problem with Reader file when we try to save a pdf version of filled in file.

    We currently create fillable forms in Acrobat XI and enable them for fill-in with Acrobat Reader.  Our end users are able to key information and save it to the enabled pdf file with Reader, but they want to create a protected version of the form so nothing can be modified once they have approved it.  They have been creating "locked" pdf versions of the completed form using CutePdf software.  The PDF files they are creating open fine with Acrobat Pro XI or our free FoxIT reader, but when we try to open the files they created with CutePDF with Acrobat Reader, they are quite distorted.  According to users, this worked with older versions of Acrobat Reader.  Please let us know if you have any suggestions (other than switching from Acrobat Reader to the free FoxIT reader.
    Thanks for the help!!
    Ken K. - 2191

    Can't endorse FoxIt or CutePDF, since I don't use either of them, and Adobe doesn't like us endorsing thrid party products in their forums anyway. On top of that I know several people who had really bad adware experiences with FoxIt, so I'd say stay away from it.
    Most likely neither of these software developers has updated THIER software to work with Acrobat/Reader XI and the problem lies with them, since PDF is an Adobe format and they must follow the lead from here, not vice-versa.

  • Problem with reading MP3 tag information

    This may be a simple fix, but I'm having no luck figuring it out. I've got an application here that scans through a given directory for all files. We are going to assume that all files below the given parent directory are *.mp3 files. Every file we find is going to have its path stored into an ArrayList. After the ArrayList is created, we will then through the ArrayList, getting the String value which is a path to our MP3 file.
    The application works well when I am simply printing out the ArrayList to the console. It's printing out everything in the ArrayList. The ArrayList consists of both directories and paths to actual files. The problem comes when I am trying to take the String from the ArrayList, pass it into my getID() method. Here is the code. i've commented the line in my main method that is giving me problems.
    * Main.java
    * @author tristan
    * Created on August 7, 2007, 4:26 PM
    package audioidreader;
    import java.io.*;
    import java.util.*;
    import org.blinkenlights.jid3.*;
    import org.blinkenlights.jid3.v1.*;
    import org.blinkenlights.jid3.v2.*;
    public class Main
        /** Creates a new instance of Main */
        public Main ()
         * @param args the command line arguments
        public static void main (String[] args) throws Exception
            /* tempDir is the directory where we will be searching for files. The ArrayList 'files'
             * is where all the file listings will be stored by using getFileListing(tempDir). The
             * for() loop get the size of the ArrayList, starts from the first index, and gets the
             * index value. The index values are supposed to be paths to an MP3 file. We will use
             * System.out.println() to print out all the paths to all the MP3s found to the console.
            File tempDir = new File ("/home/tristan/My Music");
            ArrayList files = (ArrayList) getFileListing ( tempDir );
            for(int i = 0; i < files.size (); i++)
                System.out.println ( files.get (i) );
                // getID((String) files.get (i)); // throws an exception
        static public ArrayList getFileListing ( File aStartingDir ) throws FileNotFoundException
            /* First, we check to see if our directory for the MP3s exists or not. In this case,
             * we are calling validateDirectory() with a file object passed from our main method.
             * If the directory is good, we then create a new Arraylist to store the results in.
             * We then scan through our directory and find every file within our parent directory
             * and we add the result, even directories, to the ArrayList. Once everything is done,
             * we return the 'result' ArrayList to where it was originally called from Main.
            validateDirectory (aStartingDir);
            ArrayList result = new ArrayList ();
            File[] filesAndDirs = aStartingDir.listFiles ();
            List filesDirs = Arrays.asList (filesAndDirs);
            Iterator filesIter = filesDirs.iterator ();
            File file = null;
            while ( filesIter.hasNext () )
                file = (File)filesIter.next ();
                result.add (file);
                if (!file.isFile ())
                    List deeperList = getFileListing (file);
                    result.addAll (deeperList);
            Collections.sort (result);
            return result;
        static private void validateDirectory (File aDirectory) throws FileNotFoundException
            /* This method checks to see if our parent directory that we entered is an existing
             * directory. If the directory does not validate, we will throw an exception specific
             * to the reason of not being valid.
            if (aDirectory == null)
                throw new IllegalArgumentException ("Directory should not be null.");
            if (!aDirectory.exists ())
                throw new FileNotFoundException ("Directory does not exist: " + aDirectory);
            if (!aDirectory.isDirectory ())
                throw new IllegalArgumentException ("Is not a directory: " + aDirectory);
            if (!aDirectory.canRead ())
                throw new IllegalArgumentException ("Directory cannot be read: " + aDirectory);
        static private void getID (String mp3) throws ID3Exception
            /* getID() is called by the main method. What we are attempting to do here is
             * receive the String (path to MP3 file) that is passed to us and do a test on
             * it. First, we will use the String to our MP3 and make it a file object.
             * After creating the file object, we are then using that object to create
             * an MP3 object. Now, we will read the tages from the object to determine
             * if it is an ID3 v1.0 or ID3 v2.3.0 tag. Regardless of what it is, we want to
             * print out some information to the console in the format of 'Artist - Title'.
            File oSourceFile = new File (mp3);
            MediaFile oMediaFile = new MP3File (oSourceFile);
            ID3Tag[] aoID3Tag = oMediaFile.getTags ();
            for (int i=0; i < aoID3Tag.length; i++)
                if (aoID3Tag[i] instanceof ID3V1_0Tag)
                    ID3V1_0Tag ID3_1 = (ID3V1_0Tag)aoID3Tag;
    if (ID3_1.getTitle () != null && ID3_1.getArtist () != null)
    System.out.println (ID3_1.getArtist () + " - " + ID3_1.getTitle ());
    else if (aoID3Tag[i] instanceof ID3V2_3_0Tag)
    ID3V2_3_0Tag ID3_2 = (ID3V2_3_0Tag)aoID3Tag[i];
    if (ID3_2.getArtist () != null && ID3_2.getTitle () != null)
    System.out.println (ID3_2.getArtist () + " - " + ID3_2.getTitle ());
    If I type in an actual String that is a path to an MP3, such as:
    getID("/home/tristan/My Music/Incubus - Drive.mp3"); Everything works fine. I've tried casting the value pulled from the ArrayList as a String and then passing it to the getID() method, but my exception I am getting is:
    Exception in thread "main" java.lang.ClassCastException: java.io.File cannot be cast to java.lang.String
            at audioidreader.Main.main(Main.java:38)
    Java Result: 1Line 38 is the line I have commented out. Any ideas?

    You're right. That is a bit misleading. Anyway, I
    decided to not cast (String) to it. It was a simple
    fix just like I figured, but of course I figure it
    out after I made the post.
    getID (files.get (i).toString ());fixed my problem. Thank you.But not in the correct way. You should really use the canonical path or the absolute path.

Maybe you are looking for

  • Crystal Report Lines Problem

    Experts, In one crystal report, there are more than 20 pages. Now in first page data coming fine, but in most of the pages, the lines (column lines, vertical lines) are not ending or not touching the horizontal line which really looks very odd. Pleas

  • After creating a customizing database table 'create entries disable'

    After creating the database table i want to add fields through goto-table contents-create entries but "create entries" is in disable mode how can i resolve this?

  • EoMPLS problem with 6500 and IOS SXF6 + SXE5

    My EoMPLS stopped working after one ge-wan interface gone down and up. Before the down it was working fine. The connection is between two 6500 switches, trough GE-WAN (OSM+4GEWAN) ports. One swith have IOS 12.2(18)SXF6 and the other is using 12.2(18)

  • Is 720P  960 or 1280 pixels wide?

    In FCP, the Preset choices for Sequence Settings include DVCPro 720P, which turns out to be 960 pixels wide. Panasonic brags that their D2 camera (which I just shot my first footage with) is 1280 pixels wide. Then there is the Canvas "view as square

  • Select a VI on function block does not load VI anymore

    Is there any reason why select a VI does not load a VI from my disk. It worked fine before. What could I have done to disable it?