Print out all methods in program with print statements

Does anyone know how I would be able to print out all the methods in a program. For example:
class bd220p1 {
     public static void main(String args[])  {
          int lightspeedi,lightspeedm;
          long days;
          long seconds;
          long distancei;
          long distancem;
          // approximate speed of light in miles per second
          lightspeedi = 186000;
            // approximate speed of light in Kilometers per second
          lightspeedm = 300000;
          days = 1000; // specify number of days here
          seconds = days * 24 * 60 * 60; // convert to seconds
          distancem = lightspeedm * seconds; // compute distance in English system
          distancei = lightspeedi * seconds;// compute distance in Metric system
          System.out.print("In " + days);
          System.out.print(" days light will travel about ");
          System.out.println(distancei + " miles and");
          System.out.print(distancem + " Kilometers ");
}This code would produce 5 print statements for the 4 methods:
1 Main method
2 Print method
3 Print method
4 Println method
5 Print method
Does anyone know I can write the could to accomplish this? Right now I am experimenting with try/catch statements. Any help is greatly appreciated.

It seems to me the easiest approaches (other than using a tool someone else has already written) are:
1) Compile the source, and then use BCEL
2) Try some regular expressions; it won't be perfect but maybe you can tweak it until it's good enough.
3) Parse the source, and examine the parse tree.
1 and 3 will give you much better results, but require you to use outside libraries (or write a parser yourself).
You can do 2 using standard stuff from the JDK, but you may spend a lot of trial-and-error gettng the regexps right.
Which you choose will depend a lot on what the prof giving the assignment allows.
Also he may have some particular kind of solution in mind -- did he say anything?
If you're not sure what to do, ask your prof for clarification.

Similar Messages

  • How to find out all the tables associated with particular T-code or Program

    Hi All,
    In 4.6B we have a transaction code SE49, where we can see all the tables associated with particular Transaction code or Program.
    But in ECC 5.0 or in ECC 6.0 this transaction code is not available.So is there any alternative where i can find out all the tables associated with particular T-code or Program.
    Thanks
    Shubham

    Hi,
    you are right, Transaction SE49 as well as SE48 do not exist anymore I'm afraid, they        
    are discontinued.                                                              
    You might try to create a transaction variant:                                        
    1) Start SE93 to create a transaction variant                                         
    2) Specify a name, eg. ZSE49, and choose the first option:                            
       "program and screen (dialog transaction)                                           
    3) Here specify SAPMSEUZ as program, and 200 as screen number                         
    4) Choose a suitable development class (package) if you want it to be                 
       transportable or Local (=$TMP) if non-transportable                                
    5) press Save                                                                         
    Same applies for SE48, same program but dynpro 100.                                   
    Sorry for not being able the reasons behind the decision to discontinue            
    these transactions. I suppose at least part of the functionality was               
    integrated in SE38.           
    Best regards
    Erika

  • Find out all custom concurrent program

    Hi experts,
    I am looking for the query that can bring me all custom concurrent programs. We did not follow the naming convention so that It is so difficult the find find out all custom concurrent programs. If you have that sql, please kindly share with me.
    Thanks in advance.
    HL

    That is another question, probably the question was asking the custom tables, and I found out almost custom tables. Now, I am asking about custom concurrent programs. If I base on creation_date, it seems to me that I can get 60%-70% of custom concurrent programs. But I need all custom concurrent programs. Do you have the query that can list all standard current programs. Then I can exclude them on my list and I can get the expected result.The same way you got the list of custom table you can use to get the list of custom concurrent programs.
    You can query the same tables/views and get the list of seeded concurrent programs (CREATED_BY in (-1, 0, 1, 2)). Please pay attention to the custom concurrent programs which were created by any of those users (ANONYMOUS, SYSADMIN, AUTOINSTAL, INITIAL_SETUP).
    Thanks,
    Hussein

  • Can I install new operating system without wiping out all of my programs- some of which were free

    Can I upgrade my OS without clearing out all programs such as Adobe Creative Suite, Office, etc as well as all files that I do not want to lose because many of the programs were free and do not have portable storage drive?

    brandon43 wrote:
    Can I upgrade my OS without clearing out all programs such as Adobe Creative Suite, Office, etc as well as all files that I do not want to lose because many of the programs were free and do not have portable storage drive?
    You can upgrade the OS without clearing out your programs or files, however that's no guaranty that those programs will continue to work in the new OS.
    And if you plan to jump over operating systems, like going from 10.4 to 10.6 or 10.5 to 10.7 that that will require wiping the drive of all programs and installing the new OS fresh.
    So perhaps you better start by telling us some details about your present hardware specifications, your computer model (like MacBook Pro 3,1) your OS X version, your RAM amount, your hard drive size, software you absolutely need, others that you can perhaps do without, and what and where you want to go etc. Also if you want to spend money and how much.
    You can find out about your machine by Apple Menu>About this Mac>More information.
    Your question is rather lacking on details, and people don't update their signatures so we can't go by that.

  • Print out all methods in a program...

    I am looking for a way to write a piece of code that recognizes methods, for instance if I were to put this program through the code:
    class bd220p1 {
         public static void main(String args[])  {
              int lightspeedi,lightspeedm;
              long days;
              long seconds;
              long distancei;
              long distancem;
              // approximate speed of light in miles per second
              lightspeedi = 186000;
                // approximate speed of light in Kilometers per second
              lightspeedm = 300000;
              days = 1000; // specify number of days here
              seconds = days * 24 * 60 * 60; // convert to seconds
              distancem = lightspeedm * seconds; // compute distance in English system
              distancei = lightspeedi * seconds;// compute distance in Metric system
              System.out.print("In " + days);
              System.out.print(" days light will travel about ");
              System.out.println(distancei + " miles and");
              System.out.print(distancem + " Kilometers ");
    }The code would locate 5 methods and print them out like so:
    1.main method
    2. print method
    3. print method
    4. println method
    5. print method
    So far I havent been able to find a way to do this, so any help would be appreciated. If I am vague or unclear on what I am trying to do please let me know.

    Regular expressions are rules for creating (and thus matching) strings of characters. So for example this:
    ^a*dogb+$matches "dogb", or "adogb", or "aaaaaaaadogbbbbbbb", or "aaaaadogbcat".
    There's been a regular expression library in java since jdk 1.4. Look at java.util.regex, or some tutorials. It's not something you can sum up in a couple lines; there are a bunch of little rules to learn and to apply.
    It may be easier to start out with Perl. Perl is an interpreted language with regexps built in, so it's a lot faster to fiddle around with them in perl. So for example (if you're using a real OS like linux, with Perl installed) you can type this at the command line:
    $ perl -ne 'print (/YOUR REGEXP HERE/ ? "yes\n" : "no\n");'and then type in strings on the console and see if the regexp matches them -- a quick way to experiment and learn.

  • Colors coming out different from different programs with Canon Pixma IP8500

    I have a problem with a Pixma IP8500. The colors come out much darker from iPhoto than they do from Canon's ImageBrowser and Photoshop.
    Is this normal? How can I fix this?

    Sounds like a colour management issue. Photoshop will use a different colour profile to iPhoto (I don't know what imageBrowser does?).
    Try this. Open iPhoto Preferences > Advanced and disable "Add ColorSync profile". Now print your photo.

  • Running Programs with Screen Closed

    I cant figure out how to run programs with my screen closed. For instance, I'm signed on AIM and I close the screen and when I open it back up, I'm no longer signed on AIM. It's very frustrating. Any type of assistance would be greatly appreciated. Also, is there any phone number available that will connect me directly with customer service?

    Unfortunately, unlike PC counterparts, your laptop has 1 function with the laptop on, and screen closed - Sleep.
    Sleep can be reversed with closing the lid as described above, having an EXTERNAL mouse and or keyboard and activating the computer that way.
    It is really designed to run closed when use with a large display - that is what that feature is.
    Unfortunately you either have to keep your lid open, or accept the fact that you won't be on AIM when you close the lid.
    Now please don't get offended with the last part I have to say about AIM:
    I used to hate the fact that when I closed the lid, I was kicked off AIM. I now love it. The reality is that none of us are really all THAT important that signing out of AIM is the end of the world. There's email, and there's the telephone if someone has something emergent, urgent, important, or barely important to tell someone.
    I feel like AIM has dumbed down communication as we know it, creating a world of "acquaintances" and "buddies" instead of "friends".
    Like I said, please take no offense, i just think we all deserve time away from AIM...
    Sorry there aren't any other solutions for you.

  • How to print out document list items (and with all comments!)

    Hi all,
    I am wondering how to get a good printout of document lists.
    In a web application I have some document list items and the users are adding many comments in it, so that the document list item doenst show all in the initial view, but scroll buttons to navigate up and down.
    I was surprised to read that the standard print functionality doesnt support document items.
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/68ce8391886e47e10000000a422035/content.htm
    How can I print out a list of all document list items with all comments?
    Ist there a workaround?
    thanks in advance for sharing your experiences, br, Michael

    Thanks guys for trying to help me...
    Gabriel, I not wanna do "a lot of trix" to get this out of iCal when it should be solved by iCal (from my point of view).
    Dancing Brook, Yes I hope we will see that in the future. I am convinced that there is many of us out there who want to see that function in iCal, even if they not really missed it yet.
    I have already sent a request to iCal feedback (hope they noted). Maybe they will if we are many doing so...

  • Adobe PDF plugin 10.1.5.33 does not print correctly. Some text comes out all garbled but looks fine on screen.

    I am using Adobe PDF plugin 10.1.5.33. I can open PDF files and they look fine. When I print some of the test comes out all garbled - usually labels, notes at bottom etc. If I disable plugin then when I open PDF Firefox uses Adobe PDF reader to open file and then printing is fine. I have Adobe reader 10.1.5

    I am seeing the same issue with Reader 11.0.1.36. Without the Adobe plugin enabled, no issue. Probably related to the type of font being used for the garbled text. There are many font bugs related to various fonts and various Adobe programs filed at Bugzilla. Looks like Adobe has some fixing to do with their Firefox / Netscape plugin.

  • I was using OS Snow Leopard and on 8/1/13 I downloaded Mountain Lion and found out it was not compatible with my HP printer (HP photosmart C5580) so I called Apple and asked how to get Mountain Lion off and Snow Leopard back on.  The Tech told me to

    I was using OS Snow Leopard and on 8/1/13 I downloaded Mountain Lion.  Then I found out it was not compatible with my HP Printer (HP Photosmart C5580 all-in-one) so I called Apple support and the tech told me to erase the hard drive instead of going in the time machine.  Well I did that and then it took about three hours three days a week for about three weeks on the phone with an apple tech to get all my stuff back on my computer.  I have had trouble with my printer (won't do the scan anymore and wasn't printing on my DVDs.  Also the computer keeps freezing up when it is in the sleep mode, etc.
    When I tried to list my problem on this forum it lists your OS at the bottom and mine had Mountain Lion listed as what I was using so apparently it didn't erase it.  Want to know how to get Mountain Lion off and put my Snow Leopard on so things start working right.

    Go to the  menu/About This Mac - what OS version shows there?
    Do a backup, preferably 2 separate ones on 2 separate drives.
    Revert to a Previous OS X
    Revert to Snow Leopard
    If you do revert, I'd use Setup Assistant to restore your data. This process takes a while, so do it when you won't need the computer for several hours, based on my experience.

  • How can I print out all notes?

    I have over 200 notes and I would like to print out a copy to keep as a reference. Is it possible to somehow print out all of the notes at once without having to open up each one individually and print them out.

    It's not a file, so you can't "open" one file. Every message (and note) is a single file on the computer.
    This Applescript will grab all the notes in the selected mailbox (i.e. the selected Notes item in Mail) and put them in a textEdit document.
    Note that Mail doesn't differentiate between a note and an email message, so if you run this while a normal email mailbox is selected, it will gather all of your email messages.
    tell application "Mail"
    set theMailboxes to the selected mailboxes of message viewer 0
    repeat with aMailbox in theMailboxes
    set theNotes to the messages of aMailbox
    set theText to ""
    repeat with aNote in theNotes
    set theText to theText & content of aNote & return
    end repeat
    end repeat
    end tell
    tell application "TextEdit"
    set myDocument to make new document at end of documents with properties {text:theText}
    end tell
    Copy and paste this into a new AppleScript Editor Document, select the Notes mailboxes you want to print the notes from, and click the Run button (Green button with arrow).
    This may take a while.

  • How can I print out all notes or export the entire file?

    I have around 300 notes that include a variety of information. I would like to print out a hard copy. I don't want to open and print out each one individually. Is there a way to print out all of them at once. Also, is there a way export the file so I can open it in another application like Excel or Word?

    It's not a file, so you can't "open" one file. Every message (and note) is a single file on the computer.
    This Applescript will grab all the notes in the selected mailbox (i.e. the selected Notes item in Mail) and put them in a textEdit document.
    Note that Mail doesn't differentiate between a note and an email message, so if you run this while a normal email mailbox is selected, it will gather all of your email messages.
    tell application "Mail"
    set theMailboxes to the selected mailboxes of message viewer 0
    repeat with aMailbox in theMailboxes
    set theNotes to the messages of aMailbox
    set theText to ""
    repeat with aNote in theNotes
    set theText to theText & content of aNote & return
    end repeat
    end repeat
    end tell
    tell application "TextEdit"
    set myDocument to make new document at end of documents with properties {text:theText}
    end tell
    Copy and paste this into a new AppleScript Editor Document, select the Notes mailboxes you want to print the notes from, and click the Run button (Green button with arrow).
    This may take a while.

  • Must I print out a new Alignment Page with each new cartridge?

    Do I need to print out a new Alignment Page with each new cartridge I install on my HP Photosmart C4480?  Or can I save and reuse the initial one I got when first installing my printer cartridges?  The Alignment pages all seem to be identical   when I print them out with each new cartridge I install, but I'm not examining them with a microscope.
    If I can save and reuse the Alignment page with sucessive cartridge replacements, when I am following the procedure for installing a new cartridge and the printer prompts me to print out a new Alignment page, is there an option to skip that step?  I don't recall seeing that option on the control panel window on the printer.
    Thank you!
    This question was solved.
    View Solution.

    themadtoker wrote:
    do NOT listen to this expert.
    YOU DO NOT NEED A NEW ALIGNMENT PAGE EVERY TIME YOU INSTALL A NEW CARTRIDGE
    I registered just to respond to this
    The alignment pages all look the same because they are all the same, pretty sure its a scam to let you use ink.  [snip]
    I am pretty sure you do not understand what the alignment page is for - it provides information for alignment of black vs. color and also is used to calibrate the operating energy for the color cartridge.
    You may be able to "fool" the printer by reusing an old alignment page, but the quality will suffer as you will not be running at the optimum energy.  
    You are certainly free to do what you want with your printer but please do not mislead others with misinformation.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Single photos printed in iPhoto come out all wrong

    I'm trying to print photos from iPhoto. The problem is they come out the wrong size or with the incorrect alignment (or both). I'm printing on an Epson using 4x6 photo paper. After I've believed to set up the size and print quality in the Print dialogue box, the prints come out off-center and aligned incorrectly; sometimes they come out in thumb-nail size. What is really confusing is that it seems you can set up the photo in two different ways: one in Page Setup, and one through the Print dialogue box; doing one or both changes everything, and it's always wrong. Can someone give me step-by-step help? Thanks.

    I'm afraid that I can give no solution, but am equally keen to discover and correct the issue. I have a similar problem printing from iPhoto to my HP Deskjet F380, no orientation issues (as yet) though. The print setup all seems fine and shows me what I want to print but as soon as I go to print, preview or pdf I get given something completely different and something that does not correspond to any of the other print settings. I have eliminated the printer driver as an issue - this has been re-installed and besides there are no issues with printing from any other software.

  • I cannot print out a webpage when viewed with firefox. I've removed and reloaded firefox. Same issue.

    I cannot print out a webpage when viewed with firefox. I've removed and reloaded firefox. Same issue. Printer program drop down indicates printer is offline. I bring up the same page with IE and no problem. Prints out no problem.

    Try the '''''reset''''' described here: <br />
    http://kb.mozillazine.org/Problems_printing_web_pages#Reset_printer

Maybe you are looking for

  • Battery Life on two 3G iPhones has dropped dramatically since 3.1 update...

    Hello all! I couldn't find a thread with just this problem, so I thought I would start it. My wife and I both have iPhone 3G 16GB phones and using the same apps as before, our battery life has dropped to less than a day for both of us. I would estima

  • I am trying to install XP Home Edition over Windows 7

    Hello,  I have been all over trying to resolve the problem detailed below and hope you can help me. I have a HP Pavilion Elite -  HPE 180T - OS Win 7 64 bit.  System Info: 9 GB Physical memory - 5 memory Modules - Video Card1.8GB  NVIDIA GeForct GTX

  • Part payment through app

    Dear gurus, Can we make part payment through APP? Please tell me the procedure. Thanks in advance N.M.B

  • Nokia N97 - adding apps to the front screen

    I want to add downloaded applications to the front screen. I tap on one of the empty spaces and the home screen and select "download content" this takes me onto the Ovi store website. I've downloaded a couple of applications and they appear in the Ap

  • Problems rendering

    While working on a sequence last night I found myself frequently rendering so I could view transitions or re-ordered clips but found that occasionally small parts (headed with the red line) would not render no matter which method I tried. I would the