Reading Within tags.

Hi,
Im reading in from a file and the file is as follows:
<EXAMPLE>
My name is DeeSheehan. Hello Everyone.
How are you today??
</Example>
I only want to read the lines after the <Example> line so i have the following piece of code:
while ((s = open.readLine()) != null)
if (s != "<EXAMPLE>")
s = open.readLine();
System.out.println(s);
else
System.out.println(s);
and it prints out:
My name is DeeSheehan. Hello Everyone.
</EXAMPLE>
so it skips the line "How are you today??"
Can anyone tell me please why is it doing this???

Maybe this comments will help:while ((s = open.readLine()) != null)  // read line #1
  if (s != "<EXAMPLE>")  // always true, use s.equals("<EXAMPLE>") instead
    s = open.readLine(); // read line #2, throwing away line #1
    System.out.println(s); // print line #2
  else
    System.out.println(s);
}So you effectively only print every second line.

Similar Messages

  • 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.

  • Reading EXIF Tag Attributes

    Image FIles have Properties like Width, Height, Duration, Bit Rate, Date Created, Date Modified, Date Picture Taken etc.
    I need to read these attributes ( EXIF Tag ) of these Image Files before uploading them and storing them separately in the SAP system. Does anyone know how this can be achieved thro ABAP please
    Thanx in adavance

    I doubt you'll find something like that in ABAP. If I were you, I would try to execute a command-line third-party application from ABAP.
    You can use for instance [ExifTool|http://www.sno.phy.queensu.ca/~phil/exiftool/]. I use it to work on my personal photo collections and works very well reading exif tags information, and can be used in both Linux and Windows, in case you need to save it within the Application Server.
    Cheers,
    Andres.

  • ITunes cannot read ID3 tags written by Perl module MP3::Tag?

    Greetings,
    Just trying to re-arrange ID3 information in a large set of MP3 files. Before I run the following Perl script, iTunes can read the ID3 tagging information. After writing ID3 inform ation to the MP3, iTunes no longer reads any tagging information from the MP3.
    Does anyone have any information regarding this? There is some cryptic information in the MP3::Tag POD regarding setting the "id3v23_unsync" option but that doesn't seem to alter the impact on iTunes at all. Windows and other tag readers seem to be able to read the all ID 3v1 and ID3v2 tags just fine (including the altered fields) after running the following script.
    Thanks for any suggestions/guidance anyone can provide.
    Description: the following program takes an MP3 filename as input.
    Action: It appends the value in the Album field to front of the TITLE Field. That's it! Easy!
    #!/usr/bin/perl -w
    use MP3::Tag;
    MP3::Tag-> config(id3v23_unsync=>FALSE);
    my $filename = $ARGV[0];
    $mp3 = MP3::Tag-> new($filename);
    @info=$mp3-> autoinfo;
    @albnum = split(/_/, $info[3]);
    $frame = $mp3-> {ID3v2}->get_frame("TIT2");
    print $frame;
    $mp3-> {ID3v1}->title("$albnum[0] $info[0]");
    $mp3-> {ID3v2}->change_frame("TIT2","$albnum[0] $info[0]");
    $mp3-> {ID3v1}->write_tag();
    $mp3-> {ID3v2}->write_tag();
    @info=$mp3-> autoinfo;
    print $info[0]; //print ID3v1 TITLE field
    $frame = $mp3-> {ID3v2}->get_frame("TIT2");
    print $frame; //print ID3v2 Title2 field
    $mp3-> close();
    Thanks!
    GL
      Windows XP  

    SOLVED
    Changing the config entry (Line 3 in original listing) to:
    MP3::Tag->config("id3v23_unsync",0);
    fixed the problem with iTunes.
    NOTE: This means that iTunes version 7.x still has the synchronization problem alluded to in the documentation (POD) for this Perl module. I just had the syntax wrong to set the workaround parameter.
    That aside, iTunes 7.2 works quite nicely with the modified MP3. Artwork (even though this was a modified and obscure (and legal) Bible audio, it found additional information about the MP3 in the online database).
    Kind Regards,
    GL
      Windows XP  

  • ITunes not reading ID3 tags correctly

    I have an album of mp3s, all correctly ID3 tagged (WinAMP and Windows Media Player read them fine), and when I try to add it into my iTunes library, it only add it as the filename. It does not read the artist, album, or track name from the tag.
    It is strange that it is able to read some of the id3 tags but not all.
    iTunes 6.0.4   Windows XP Pro  

    Something else on your system is probably changing the tag outside of itunes. For instance, WMP is set to get album info from the internet.
    iTunes isn't constantly scanning your library for any little tag change (a good thing, otherwise it would use 100% CPU all the time). When you go to play it or get Info, it DOES read the tag info.
    Then again, I might not understand your itunes preferences settings. I have mine set for itunes not to organize my files and not add them to the itunes library.

  • How to parse xml file to read the tags

    Hi All,
    I am having a requirement to read the tags from the xml file(xml parsing).
    The main issue is *xml file is stored in the table with xml type column* (not placed directly in the server) and we have to read the tags from that xml file.
    Please help me to achieve it.
    Regards,
    Akshata
    Edited by: Akshata on Mar 21, 2013 3:44 AM

    Hi,
    Akshata wrote:
    The main issue is xml file is stored in the table clob/blob type column (not placed directly in the server) and we have to read the tags from that xml file.How is that an issue? On the contrary, it's better when the data already resides in the database, though it should be in an XMLType column to leverage the full capacity of the Oracle parser.
    What's the datatype of the column exactly? CLOB or BLOB?
    Either way you'll have to convert in to XMLType datatype using the XMLType constructor.
    Did you go through the countless examples on this forum? Examples with XMLTable should be helpful.
    Post some sample data and database version if you need additional guidance.
    Thanks.

  • How to read empty tag value.

    Suppose there is a tag name with values ,
    <Name>Raj</Name>
    I am able to read the tag value 'Raj' ..
    But if the tag is like
    <Name /> I am getting null pointer exception while reading the tags value..
    I have put the reading part in a try catch block .Is there any other efficient way to do it.

    try {
            BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder = factory.newDocumentBuilder();
             Document doc = builder.parse(inputSource);
             NodeList list = doc.getElementsByTagName("*");
             for (int i=0; i<list.getLength(); i++) {
               Element element = (Element)list.item(i);
               NodeList fstNm = element.getChildNodes();
    *//  Here is where i get null point exception because of tag being*
        *like <test/> ,whereas other tags have vakue like <test>value </test>*
               String check_null;
               try {
                check_null = (((Node) fstNm.item(0)).getNodeValue());
               catch(Exception ex) {
                   check_null="";
               //System.out.println(element.getNodeName() + ":"  + ((Node) fstNm.item(0)).getNodeValue());
               //if((((Node) fstNm.item(0)).getNodeValue()) != null)
               hm.put(element.getNodeName(),check_null);
               //System.out.println(element.getNodeName() + ":"+ (((Node) fstNm.item(0)).getNodeValue()));
           catch (Exception ex) {
               System.out.println("Exception in PostPaidInfo Parsing") ;;
               System.err.println(ex.toString());
               return 1;
         }I have just caught the exception ,I want to know is there any other way . The null pointer exception arises not because of string being null , But because of the internal parsing.
    Edited by: CulbOy on Apr 29, 2010 12:13 PM

  • Read array tags with OPC (not DS) -- LV6.1

    Hello DSC experts:
    The Siemens OPC server to which I am connected publishes array tags and I cannot change that fact. I can read those array tags using the "Datasocket Read Double Vector.vi" but as the number of tags grows this slow method becomes unreliable. Instead I would like to use DSC but I do not see any Vi that allows me to read vector tags? Like I said I have to live with the OPC configuration as it is today hence I do not think that going through the flatten/unflatten to string method is an alternative.
    Any clue?
    Thanks a lot,
    Chris

    Can you do any kind of array indexing when addressing the tag inside the opc server?? Something like tagname.xx or tagname[xx] where you would select a portion of the tagname array data. Could you talk directly with the VISA drivers and use a read multiple registers command instead of a DSC driver?? To my knowledge, the tag engine does not support array addressing for a tag datatype. I do use the method of flattening an array of data into a binary string and writing it to a memory tag, but the array data is created inside labview. I submitted DSC tag array datatype to a request list quite some time ago but never heard anything about it again. I wonder if a DDE connection could be established to read string data. Then do a string to number conversion. What version
    of Siemens hardware/software are you using?? I think the tag engine really is lacking with respect to the capabilites of the latest OPC software. I would love to see NI directly integrate an OPC program like KEPWARE so you did not have to use the tag engine. Are you using serial or ethernet communication??

  • Gallery: read Metadata tags

    Hello,
    LR-WEB-Gallery provides options to read metadata tags and insert them into WEB-pages by means of this code:
    ["perImageSetting.keywords"] = {
      enabled = true,
      value = "{{com.adobe.keywords}}",
      title = LOC "$$$/WPG/HTML/CSS/properties/ImageKeywords=Keywords",
    and then using the selector and the template text editor in the WEB-UI.
    This method is a bit cumbersome.
    On the other hand some tags can be inserted directly into the details.html like so:
    <p>$image.metadata.keywords</p>
    I prefer this method as it allows to place the desired tags indivdually on the grid.html or details.html.
    I am now curious to learn about a list of the tags that can be read that way because I found that many very common tags are not read that way.
    A list of tags is in the SDK 3.0 but I can't get it to work for most of the tags (not all).
    The values for all these tags are in database (Library Module) and the data has been saved to xmp-sidecar files.
    Still, the data is not read and results as 'nil'.
    Hopefully this is only a syntax issue only.
    Below some examples of common tags not being read:
    $image.metadata.title
    $image.metadata.copyright
    $image.metadata.location
    $image.metadata.isoCountryCode
    $image.metadata.city
    $image.metadata.state
    $image.metadata.country
    ...results
    Location:nil
    ISO Country Code:nil
    City:nil
    Thanks for replies.

    Hi,
    I'm referring to the "TAGS" field.
    I know they appear, but do they serve any purpose beyond simply appearing there? It seems redundant with the DESCRIPTION field. We were told the TAGS field would server some other, more sophisticated purpose, and I wanted to know if that purpose had ever been implemented. Our editorial team doesn't see any value in creating the content for the TAGS field if all it does is display in the browse mode. And I tend to agree. The TAGS field is not searchable as far as I know, or is it???
    Kindest regards,
    Brad

  • Nokia 5310 XpressMusic won't read MP3 tags

    Hi,
    I got the 5310 for Christmas of 2008. For a long time it was reading MP3 tags just fine (up until maybe three or four months ago). But, now, it seems that most of my MP3s I transfer, it won't read the tags on it. Usually if the album art is embedded to the MP3 it'll still read that, but it won't read song title, artist, album, track number, etc. However, this doesn't affect ALL of the MP3s. Maybe 15-20% of my MP3s are still read, even though they're tagged with the same program at the same time (I've tried tagging with both foobar2000 and iTunes and had the same result as far as what the phone will read). I don't know why it does this; I can open files directly off of my phone to foobar2000 and iTunes and both programs read every tag on every MP3 fine.
    Does anyone have suggestions for what to try to fix this? Maybe a different tagging program or something to do to the phone to get it to read the tags. It gets really annoying not having the option to sort by artist or album.
    Solved!
    Go to Solution.

    The music player reads ID3v2 tags and NOT ID3v1. Make sure that you have them in place. Some PC applications show and modify only ID3v1 tags. I don't use either of the apps that you mentioned, so, can't tell you if they are doing it. What I would suggest is to check the ID3v2 tags using Winamp/jetAudio (in windoze) or BMP/mplayer/amarok (in linux), and if necessary, update it and then transfer back to your phone.
    Cheers,
    DeepestBlue
    5800 XpressMusic (Rock Stable) | N73 Music Edition (Never Say Die) | 1108 (Old and faithful)
    If you find any post useful, click on the Green "Kudos" Button on the left to say Thank You...

  • How do I set BI Publisher to read html tags from the database?

    How do I set BI Publisher (Release 10.1.3.4) to read html tags from the database? For example if the text is quoted with a bold tag I want my output to display the text in bold. Is there a setting or something I can set?

    I took a look at Tim Dexter's blog as suggested and the sample worked, but for the elements in the xml file not for the value coming from the database, however this is good to know as well!
    I have data in the data base column which looks like this:
    'MS Applied <B(bold tag)> Mathematics</B(bold tag)>University of Southern California'
    I want the data to be rendered like this:
    'MS Applied <B>Mathematics</B> University of Southern California'.
    In Report Builder on the property sheet I would set Contains HTML Tags property to Yes and the report would render correctly.
    In BI Publisher 10.1.3.4 I can not seem set it to read this I have change the configure properties of the report to Character set to HTML and Make HTML output accessible to True. I just can't figure out what I'm missing.
    Thank you for any assistance you can offer.

  • Read MP3 tags from HTTP mp3 streaming

    Hi , how i can read MP3 tags from HTTP mp3 streaming (streaming url : http://94.25.53.133:80/nashe-9)
    Regards
    Alex

    Hi , how i can read MP3 tags from HTTP mp3 streaming (streaming url : http://94.25.53.133:80/nashe-9)
    Regards
    Alex

  • Looking for reader GeoTIFF Tag with JAI

    Hello , I'm looking for a java code about Geotiff.
    I want to read geotiff tag. How can I do?

    Hi...
    I have same question. I replied you for getting the information wether you got anything for that or not. If you got any idea then let me know how it work.

  • Read HTML tags and Save Images in web page

    I had problem with reading HTML tags and save all images in that page. I can source code in web page but I dont know how to Identifly the image tag ( IMG tag ). I think i want to use string tokenizer class.
    But i dont know how to use it in my problem. If any one know how to do it. reply this.

    cnapagoda wrote:
    I had problem with reading HTML tags and save all images in that page. I can source code in web page but I dont know how to Identifly the image tag ( IMG tag ). I think i want to use string tokenizer class.
    But i dont know how to use it in my problem. If any one know how to do it. reply this.If you have a big, long string with HTML content in it you might try splitting on a regex like so:
    String html = ...
    String[] imgTags = html.split("<img.*?>");[http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)|http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String)]
    to get your image tag data and then parsing that to get the src attribute. You can either treat this problem as a big string-parsing problem, or getting some HTML DOM library and using that to structure the page as a tree for easier access.
    If you want more help you'll have to show the code you have so far. We can't write this for you.

  • How to read a tag of a video file

    i try to create an application that can read audio and video file with java.
    But my probleme now is that ican't read the tag of video file.
    can you help me about how to read the tag of video file like the duration of video and frame rate and the other information about the video file.Thanks

    i try to create an application that can read audio and video file with java.
    But my probleme now is that ican't read the tag of video file.
    can you help me about how to read the tag of video file like the duration of video and frame rate and the other information about the video file.Thanks

Maybe you are looking for