Comparing the content of the file

Can somebody help me make a program that checks the comments of a program. it goes something like this You will be checking the /**/ of the program only. I have a sample code but it is not running. Pls help me
import java.io.*;
import java.util.*;
class Check
     public static void main(String args[])
          boolean sw;
          BufferedReader in = new BufferedReader(new FileReader("monkey.java"));
          String str;
          String ch;
     //     String in =var.readLine();
          int state = 1;
          while ((str = in.readLine()) !=null){
          char ch = in.getAnyChar();
          switch(state){
               case 1: //Q1
                    if (ch =='/')
                         state = 2;
                    else if (ch == '*')
                         state = 6;
                    else
                         state = 1;
                    break;
               case 2: //Q2
                    if (ch == '*')
                         state = 3;
                    else if (ch == '/')
                         state = 6;
                    break;
               case 3: //Q3
                    if (ch == '*')
                         state = 4;
                    else if (ch == '/')
                         state = 3;
                    else
                         state = 3;
                    break;
               case 4: //Q4
                    if (ch == '/')
                         state = 5;
                    else if (ch == '*')
                         state = 4;
                    else
                         state = 3;
                    break;
               case 5: //Q5
                    if (ch == '/')
                         state = 2;
                    else if (ch == '*')
                         state =     6;
                    else
                         state = 5;
                    break;
               case 6: //Q6
                    state = 6;
                    break;
          if (state == 5)
               System.out.println ("Errors Found");
          else
               System.out.println ("Compilation Complete");
     in.close();
}

Crosspost
http://forum.java.sun.com/thread.jspa?threadID=597939&messageID=3177673

Similar Messages

  • How to compare the files from one server to another

    Hi !
    I want to compare the files present in one server to another server. I had to list out the files which is not present in the server and import those files to an excel file. There are lot of folders and lot of files present inside those folders. I want a java or jsp or javascript program code for this or any site which indicates how to do. What are the requirement for this program to implement like any tool or any other techniques. Please can u help me out.

    No ... The package mentioned in
    http://www.oracle-base.com/dba/miscellaneous/ftp.pks
    this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
    So it is NOT correct that this code transfer the file between two location & with in server..

  • Spry compare the file size

    So for the example :
    http://labs.adobe.com/technologies/spry/demos/gallery/
    I have to say that those Spry .js includes are huge in file
    size for what they do :
    http://labs.adobe.com/technologies/spry/includes/xpath.js
    64.9 KB
    http://labs.adobe.com/technologies/spry/includes/SpryData.js
    90.4KB
    http://labs.adobe.com/technologies/spry/includes/SpryEffects.js
    52.5
    So just including the .js and not including the overhead of
    the xml and images the application file size is at 207.8 KB now
    that is fat for what is a very simple photo gallery. Something like
    this built in Flash would probaly be a quater or less than this in
    file size and would look a hell of a lot better. I cant really
    understand the rationalle to doing it like this when a flash client
    is more reliable and in the odd case of not having Flash the
    install is not equal to the overhead of all these .js files. What
    you guys think ?

    The benifits of Spry, as mentioned by Andrew, became obvious
    to me on a recent project. I am co-developing a site and my partner
    has no Flash skills. We wanted to expose enough of the code and/or
    file structure of the site so that he could do updates without
    flash and eventually teach the client to do their own updates.
    We're using the gallery widget where the client needs to have the
    pics changed quite often. So, all we have to do is change the pics
    and update the xml files. I have used xml files with Flash, but my
    partner feels less intimidated with the 2 step process. Plus, the
    code used on the html pages is exposed enough for us to easily
    change many other settings.
    Also, I'm encouraged by the news that the Spry js will be in
    a compressed/ condensed version soon.
    I do love Flash, but Spry came along kind of like the Perfect
    Storm for use in my project.
    I fell it will be another tool in my box to use when
    appropriate.
    stmark

  • Get the file name into a Odi variable

    Hi,
    I need to get the file name into odi variable like ..A/ETC/file.txt
    For eg.the filename file.txt should get store in a variable.
    Then i want to compare the file name stored in the variable with some other value.
    Please suggest.
    Thanks.

    in package,
    declare the variable, then evaluate it with another variable, generally using # syntax
    if the variable is date type, suggest to use : syntax, because # will treat the variable value as text value
    in loadplan
    use case when syntax,

  • Can we compare file contents of two files in the Application server?

    Hi,
    A file is generated daily to the application server. and i need to compare the generated file to the file generated on the previous day and prepare a report.
    Can we compare file contents of two generated files present in the Application server?
    If there is any alternative, please suggest.
    regards
    cs

    yes we can compare if the app server is Unix.
    cmp compare two binary files and report if different
    cmp is silent if the files are the
         same;
    if they differ, the byte and line number at which the first
    difference occurred is reported.
    REPORT ZUNIX line-size 400
                    no standard page heading.
    data: unixcom like   rlgrap-filename.  
    unixcom = 'cmp file1 file2'.
    data: begin of tabl occurs 500,
            line(400),
          end of tabl.
    data: lines type i.
    start-of-selection.
      refresh tabl.
      call 'SYSTEM' id 'COMMAND' field unixcom
                    id 'TAB'     field tabl[].
    "if the files are different then you will some content in tabl
    Regards
    Viajy  Babu Dudla

  • Is there a way to compare the contents of a library by comparing itl files or some other files?

    Is there a way to compare the contents of a library by comparing itl files or some other files?
    I need to compare the contents of my current library to one that existed 2 months ago but ALL I have is the itl file from 2 months ago.  Can this be done?

    You are correct, many people have noticed over the years that Sound Check does not work as advertised.
    A more effective approach is to treat the files with a 3rd party volume normalization program. Although I have not personally used it, many users on this Forum have reported good results from an inexpensive program called iVolume.

  • Comparing the contents of two files

    I have two ASCII files.
    The files contain data from two identical tables in "|" delimited form.
    I need to compare the two files and determine if there is any difference between the two files.
    Any inputs will be appreciated.
    Thank you.
    Ramesh

    In Windows I've found a piece of shareware called WinMerge to be very useful. Try using Google to find it.
    Cheers, APC

  • How can i compare the contents of two folders ?

    how can i compare the contents of two folders and find out which files are in one but not in the other?? Knowing how to do this would be the best thing ever, especially when dealing with a large number of files. Often, for instance, I'm dealing with a large number of images, processing them, and saving the retouched ones to a new folder, and need to check that they are all there. If there are say three files missing in the second folder (out of say a hundred in total) being able to automate the process of elimination would be very useful. Please help!!!
    B

    I really wish I knew the answer to this. I work between two macs, a G5 and MacBook Pro when I'm on the go. Each time I move from one to the other I have to copy all my files to the computer I'm going to work on, so I end up with the same files being duplicated. It's not a problem if it's not much data but in my case the it can be to 30GB, mostly graphics files, photoshop, motion, final cut pro, etc.
    There's has got to be a way automator can make a comparison between two folders to sort out what's changed and what's remained the same. It would be nice also if this feature could be done globally on the hard disk using spotlight's technology to stop files being duplicated in places you didn't even know about and taking up valuable disk space. I'm not sure how this could be done.
    Any bright ideas Apple?

  • Get modified date inside the File content of CM

    hi,
    In CM I have uploaded a file and have set the permission to modify the file to a group of users.Now when each and every time any user modifies the file content I want to have the modified date inside the updated file.
    How can i achieve this?.....
    Please help.....
    Thanks in advance,
    shami.

    Hi All,
    @Parvathy:There is no such property on your files, you should create one in your filter and depending on this custom property your filter should decide if a document update is required or not.
    As already said follow this:
    You have a content filter which can do updates to these files:
    -- Content filter sets a custom property new_modifieddate on each resource after updating resource. (new_modifieddate==cm_modified of resource)
    -- It compares new_modifieddate with cm_modified of resource to determine if it should update the resource with cm_modified.
    @Shami: Use some logging in your Filter code, so that you can make sure your code is being executed. One more way is to dubug you code by setting break points in NWDS (Ofcourse the server should be in debug mode for this option).
    logging :
    http://help.sap.com/saphelp_nw2004s/helpdata/en/a0/58db515b95b64181ef0552dc1f5c50/frameset.htm
    debug:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/5d/31e540b1278631e10000000a1550b0/frameset.htm
    Greetings,
    Praveen Gudapati

  • How can u get the matching percentage whenever compare the pdf files(compare the strings)

    Actually I want matching percentage whenever compare the pdf files.First I had completed 
    read the pdf files content into string
    my code like as
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.IO;
    using iTextSharp.text;
    using iTextSharp.text.pdf;
    using iTextSharp.text.pdf.parser;
    namespace WindowsFormsApplication1
    public partial class Form1 : Form
    string str1;
    string filename;
    string path;
    string str2;
    public Form1()
    InitializeComponent();
    private void button1_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox1.Text = path + "\\" + filename;
    private void button2_Click(object sender, EventArgs e)
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.CheckFileExists = true;
    openFileDialog.AddExtension = true;
    openFileDialog.Filter = "PDF files (*.pdf)|*.pdf";
    DialogResult result = openFileDialog.ShowDialog();
    if (result == DialogResult.OK)
    filename = Path.GetFileName(openFileDialog.FileName);
    path = Path.GetDirectoryName(openFileDialog.FileName);
    textBox2.Text = path + "\\" + filename;
    public static string ExtractTextFromPdf(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result = text.ToString();
    return result;
    public static string Extract(string filename)
    using (PdfReader r = new PdfReader(filename))
    StringBuilder text = new StringBuilder();
    for (int i = 1; i <= r.NumberOfPages; i++)
    text.Append(PdfTextExtractor.GetTextFromPage(r, i));
    string result1 = text.ToString();
    return result1;
    private void button3_Click(object sender, EventArgs e)
    str1 = Form1.ExtractTextFromPdf(textBox1.Text);
    str2 = Form1.Extract(textBox2.Text);
    }Finally how can u get the matching percentage whenever compare the pdf files(compare the strings)please help me.thank u

    Hi,
    Based on your code, I see your code related to
    iTextSharp Pdf.
    iText is a third party library to create PDF originally written for java. iTextSharp is
    the C# adaptation of that library.
    Question regarding iText are better asked on the iText forum, rather than the Microsoft Forum:
    http://itextpdf.com/support
    Thanks for your understanding.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to read the contents of XML file from my java code

    All,
    I created an rtf report for one of my EBS reports. Now I want to email this report to several people. Using Tim's blog I implemented the email part. I am sending emails to myself based on the USERID logic.
    However I want to email to different people other then me. My email addresses are in the XML file.
    From the java program which sends the email, how can I read the fields from XML file. If any one has done this, Please point me to the right examples.
    Please let me know if there are any exmaples/BLOG's which explain how to do this(basically read the contents of XML file in the Java program).
    Thank You,
    Padma

    Ike,
    Do you have a sample. I am searched so much in this forum for samples. I looked on SAX Parser. I did not find any samples.
    Please help me.
    Thank you for your posting.
    Padma.

  • Is it possible that a document (in this case an Appleworks or Movie Magic Screenwriter) can be lost forever, but it's contents somehow remain as other file types elsewhere? I have an old hard drive and I need to locate the contents of these files.

    I have a 20 gig hard drive from a 2001 iBook. When my iBook crashed back in '04, there was a screenplay on there that was not saved anywhere else. It has tremendous sentimental value to me, and I would really like to retrieve it. I've ran some data recovery software that's uncovered a gargantuan amount of data, most of it being completely unreadable to me.
    Additionally, I have found an AppleWorks file that could be the script, but it is ZERO bytes in size, and Pages won't even open it, saying that it is not a valid AppleWorks file.
    So I'm curious...is it possible that the document is lost, but somehow the contents of it are somewhere else on the drive as metadata in other unreadable formats. And if that's the case, how would I go about translating the unreadable data back into something that IS readable? 

    Hello,
    toddisalive wrote:
    Additionally, I have found an AppleWorks file that could be the script, but it is ZERO bytes in size, and Pages won't even open it, saying that it is not a valid AppleWorks file.
    if the size of this file is really ZERO bytes, either the original file contained an empty data fork and a resource fork which was stored elsewhere (*) or the file is too damaged to retrieve anything. Moreover, as AppleWorks never generates file with empty data fork, at least to my knowledge, ....
    Concerning the Movie Magic ScreenWriter files, the application seems to exist for Yosemite http://www.write-bros.com/movie-magic-screenwriter.html ( but it seems "expensive"  and I do not know if it accepts to import old files )....
    (*) maybe in .TOTO or __MACOSX/.TOTO if the filename is TOTO

  • When I go to my downloads folder on my dock and click the file all the content shows up but as soon as I go to open it in the finder, I get a blank window. Has anyone else had this problem, if so, How do you fix it.

    When I go to my downloads folder on my dock and click the file all the content shows up but as soon as I go to open it in the finder, I get a blank window. Has anyone else had this problem, if so, How do you fix it. I also cant delete anything from this folder because of it. Any help would be greatly appreciated.

    Hey Allen,
    I am having the same issue here in September.  How did yor situation get resolved.  My iPad Siri works great.  My iPhone 5 Siri has been out of comission (OOC) for almost a month and I am beginning to get a little frustrated since Siri works so well in July....ANY assistance would be highly appreciated... Thanx

  • How to read the contents of attached files

    Hi,
    I am designing a Form using LiveCycle Designer 8.0
    Scenario:
    User can attach the file through "Attachments" facility provided on Adobe  Reader.
    The requirement is to attach 3 documents and post it to SAP system using Web services.
    I am using the following code(which i got from this forum only) to find the number of files user has attached.
    d = event.target.dataObjects;
    n =  d.length;
    xfa.host.messageBox("Number  of Attachments: "+n);
    //Displaying  the names of the Attached files
    for( i =  0; i < n; i++ )
    xfa.host.messageBox("Name  of the file: "+d[i].name);
    My problem: is how to read the contents of the attached files so that I post it to SAP using Web services
    Thanks in advance!!
    Taha Ahmed

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • My home page is google and it works but when I open a new tab it displays an error message :Firefox can't find the file at chrome://quick_start/content/index.ht

    I've made sure a dozen times that my home page is set correctly, and when I hit the home button next to the search bar it works and takes me right to google BUT whenever i open a new tab i get the error that my page cannot load and the web url that it keeps trying to remember is in the error message:
    Firefox can't find the file at chrome://quick_start/content/index.html.
    of course the last dot is not the url anymore but the end of the sentence for the error message, but i don't ever use chrome ever on my laptop only my cell so what is going on????? help fix god please!!!!!!

    Do you have the FastStart extension?
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to save the RichTextBox Content in Text file

    hI ,
    I NEED TO SAVE THE RichTextBox Content in text file ? 

    If this IS a LabVIEW question, here's an example of how to load a rich text file (to help if you don't know how to get a rich text in LabVIEW).
    If you have a Rich Text Box, you can use the invoke method "SaveFile" to match the function you linked to.

Maybe you are looking for

  • Fill - In Form no longer working

    I originally had a fill-in form. Once it was saved, I could no longer access the fields to type in. It also will not let me scroll in parts of the application I am filling out. Thanks for your help in advanced!

  • Email won't print

    Using Mac mail, when I try to print an email, only the header prints, not the body of the email. Sometimes I can hit reply and the new window opens and it prints, but it's only intermittent. I've also tried opening the mail in a new window, but the b

  • Deleting/hiding apps

    Can someone explain to me the difference between hiding and deleting apps?  If you delete an app at the "shaking x" is it gone forever?  I read somewhere that apps cannot be deleted.  Is that true?  What is the purpose of hiding?  I am trying to clea

  • Map of collection

    Hi, has someone an example for a persistent map with a string as key and a collection of strings as values? Is it necessary to build a persistent class to hold the collection? Can this be optimized? Cheers, Andreas

  • Where to set Java system parameter for embedded WLS in JDev 11g?

    Hi, I am trying to test web service invocation via JAX-WS proxy generation on Jdeveloper 11g. When I test client code, I got following error message. Exception in thread "main" java.lang.Error: Jaxrpc 1.1 method is not supported.      at weblogic.web