Ugly code please advise

Hi
When I need to access a text file I am using this type of code. I think it's ugly but at least it works. Can someone post the best practices.
I do not want the method to throw an exception and I want to be sure the input stream is cleanly closed.
The try block in the finally block looks really ugly... Give your opinion!
Thanks
static public String getInfo(File file, String info)
        String resu = null;
        InputStream source = null;
        try
            source = new FileInputStream(file);
            MimeMessage message = new MimeMessage(null, source);
            //  do some action that may fire an exception
        catch(Exception io)
            logger.warning("impossible to find info " + info + " in " + file.getName());
            logger.warning(printex(io));
        finally
            try
                source.close();
            catch(IOException io)
                Utilities.logger.warning("error "+io);
        return resu;
    }

public static String getInfo(File file, String info)
          String resu = null;
          InputStream source = null;
          try
               source = new FileInputStream(file);
               MimeMessage message = new MimeMessage(null, source);
          catch (FileNotFoundException e)
               e.printStackTrace();
          catch (MessagingException e)
               e.printStackTrace();
          finally
               try
                    if (null != source)
                         source.close();
               catch (IOException io)
                    System.out.println("");
          return resu;
     }

Similar Messages

  • Hard drive failure codes - please advise

    Hi,
    HP Dv6 Laptop - Product No.: A7N52EA#ABU. Laptop Serial No. 2CE148345f
    I have a 11 month old HP Dv6 Laptop and Just before Christmas 2013, the laptop started experiencing several blue screens saying the hard disk is becoming unstable and also the one blue stop screen which need a hard boot from the on/off button.  The laptop will boot to desktop (apart from the blue screens mentioned before), however, it is experiencing very regularly black screens  leading to the laptop running extremely slow at start-up and impossible to use sometimes, leading to the laptop hanging with a black screen waiting for the desktop to load which is very frustrating as it used to be very fast and from one day to the next this happened and has remained ever since. I thought it was since several windows updates one night before Christmas 2013....well that's what I thought. 
    Simple things have become painful to do such as just loading photos or simply copying and than pasting text. I get these hanging delays (but it does do eventually if patient).
    So I ran the HP diagnostic tool at start-up with the F2 button and ran both the startup test and hard disk test. The result and this is my concern, is that the hard disk short DST has failed with several failure codes, all similar but slightly different: GTSEL0-6J770R-QFPH4K-60T303,  GTSEL0-6J770Q-QFPH4K-60TK03, GTSEL0-6J770S-QFPH4K-60SK03 which are all hard disk failure codes I understand according to failure codes listed in this forum. I tried running the longer advanced hard disk scan but immediately these failure codes appear and says to contact HP with codes.
    My question - Is my hard disk at risk of imminent failure and needs replacing with all thats been happening - blue screens rarely / black hanging screens a lot of the time?
    I thought my laptop was still under warranty as when I check this on bootup in the bios it says the warranty started in March 2013. I bought the laptop new in Feb 2013 with what i thought was a 12 month warranty off an Ebay seller. However, I run the HP warranty check on this website and it says that it has expired on 10/4/13 which is curious!
    Would welcome any assistance or technical advice you can offer me as I don't know what to do next.
    Regards
    Steve

    With DST failures the hard drive definitely needs to be replaced. You will also need Recovery Discs to install your OS and software/drivers. Hopefully you made a set using HP Recovery Manager?
    Your laptop has a 750GB hdd and you will need one of at least that capacity in order to use Recovery Discs. Laptop hdds can be purchased quite reasonably and are easy to change.
    Your Maintenance & Service Manual will be helpful in replacing the drive.
    http://h10025.www1.hp.com/ewfrf/wc/manualCategory?cc=us&dlc=en&lang=en&lc=en&product=5211159&query=A...
    As far as Warranty- it is hard to determine exact date when purchasing from a third party seller.The warranty may have started when he purchased it for resale. 
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • How to code this - Please advise

    Dear friends,
         Please advise as how to code the below scenario in order to obtain the best performance.
    I've an internal table IT_BSAD.Now I've to check if in the combination of bukrs,augbl,auggj,kostl,prctr,gsber,aufnr, if there is a single record in IT_BSAD, then it should be appended to IT_BSAD1 & if there are multiple records, then those should be appended to IT_BSAD2. In any case IT_BSAD1 & IT_BSAD2 should not contain duplicate records & records in IT_BSAD = records in IT_BSAD1 + Records in IT_BSAD2. I coded it somehow but it hangs in case of million of records. Please advise me the best way of doing it.
    I'll appreciate any help in this regard.
    Thanks:
    Gaurav

    prepare a sorted table with key bukrs,augbl,auggj,kostl,prctr,gsber,aufnr
    loop it_basd assigning <fs_basd> .
    at new sufnr.
    lv_index = 0.
    endat.
    " move the fields to it_basd1 work area
    "append it_basd1
    lv_index = lv_index + 1.
    if lv_index > 1.
    if lv_index = 2.
    read it_basd1 into iwa_basd2 with key  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.
    append iwa_bsad2 into it_bsad2.
    delete from  it_basd1 where  bukrs,augbl,auggj,kostl,prctr,gsber,aufnr.
    endif.
    " move the fields of <fs_basd> to it_basd2 work area
    append iwa_bsad2 into it_bsad2.
    endif.
    endloop.
    hope this will help
    Nafran

  • HT4623 Apple IPhone is not accepting my security code on my credit card unable to make purchases on my IPhone anymore. Please advise already called my bank so it is a apple problem happening.

    Apple IPhone is not accepting my security code on my credit card unable to make purchases on my IPhone anymore. Please advise already called my bank so it is a apple problem happening. I was trying to purchase poker chips from world series of poker app.

    My download speed during this test was 6.63 MB so fast enough for the App Store.
    This youtube movie shows what happens: http://m.youtube.com/#/watch?v=jPa_W0PrL5c
    The App Store is generally very slow.
    Sean

  • I purchased Creative Cloud through the Employee Purchase program. Had to reimage system. Need help reinstalling application. I have "redemption" code, but get error saying it has already been redeemed. Please advise.

    I purchased Creative Cloud through the Employee Purchase program. Had to reimage system. Need help reinstalling application. I have "redemption" code, but get error saying it has already been redeemed. Can you please advise how I go about getting my software reinstalled? If I was given the serial number when I redeemed, I don't have any record of it.
    Thank you,
    Starla

    Hi Starla Mehaffey,
    I would suggest you to sign in with your Adobe ID during installation and your product will automatically recognize your membership details.
    Refer this Link for any further assistance:- Redemption Code Help
    Hope that helps,
    Regards,
    Rahul Tyagi

  • I get Error Code 1 when using the installer.  Please advise.

    When running the installer, it quits with the message:  Error Code 1.  Please advise how to resolve @this error.

    Gener7:  Good morning.  Thanks for speedy reply.  I’m running Windows 7 on a Dell Studio laptop computer.  I have CS6 installed, and it runs okay.
    I ran the CC Cleaner tool to uninstall Photoshop CC.  PCC kept crashing every time soon after I tried editing an image.  I gave up.  After the cleaning, I tried to re-install PCC.  The error code 1 showed each time I ran the installer.
    Please advise.
    Thanks.
    ==============

  • Please advise how I can register my Photoshop Starter Edition when I apply I do not receive an unlock code so I am unable to continue to use the program and all my photos are locked in, please advise, thanks John

    Please advise how I can register my Photoshop Starter Edition when I apply I do not receive an unlock code so I am unable to continue to use the program and all my photos are locked in, please advise, thanks John

    Please refer to the appropriate Forum, this one is dedicated to Photoshop proper.
    Photoshop Album Starter Edition

  • Content of a presentation I will give - Please advise of faults

    Hi,
    As I mentioned in another thread I have to give a presentation on a chosen subject, I chose Java. This is quite important, at least for me it is anyway, I need to know what I am talking about and believe in what I am saying, I visit a seminar in July and this is about the most important part as well as a UNIX assignment. I have listed some of the things I will say below, please advise with what you might disagree with, if you can be bothered that is, I would be grateful :). If I get this wrong I dont get asked back to the academy full time to become SCJP certified and placed in the indusrty. I dont always want to stuck in retail :(
    Title - The origins and benefits of Java
    The early days
    Java was part of a 1991 effort by Sun to produce a language and enviroment which would enable consumer electronics to be able to communicate with each other, they saw this as one of the next big things in I.T.
    The sun team which James Gosling lead the coding side, set out to make an architecture neutral programming language which would be simply to use, secure and portable. Java was origianally called oak but didnt survive a patent check and was later renamed to Java.
    Although, given there intial goals the project failed and they were turned down when showcasing a PDA called star 7 to potential customers within the industry they still had a created an extremley useful language in Java which was yet to realise its full potential.
    Years ticked by before Javas big break came when Sun teamed up with Netscape to release the Hotjava browser which brought animation amongst other things to the Internet, its worth noting that Java was originally designed independant of the Internet but was later found to be a perfect match.
    What is Java
    Java itself is similar to both C and C++, it borrows its syntax from C and its object model from C++
    Java is seen for a high level language anyways as easy to learn
    Java code compiles slower than C/C++ one may ask why would we need Java?
    Java's benefits
    Java code compiles not into Native code like other languages, this is the main reason it runs slower but is the same reason Java is portable and secure.
    This means a couple of important things in the world of networked computing, Security and portability.
    Java code compiles into bytecode which is then interperted by a Java virtual machine (JVM). This means that only the JVM needs to implented for each different type of CPU or operating system. Where the internet or corperate networks are concerned this is a major plus as both are made up of many different machines.
    Other benefits Java offers are Garbage collection, this is automatic memory managment, once the progam has finshed with an address in memory its automatically freed up, in other C/C++ this is left to programmer and can lead to errors and is also a waste of resource.
    Also, in Java there are not Pointers like C/C++ instead, Java uses references, this is also a major plus in most cases, although pointers are moe powerful they cause many errors, java eleminates these errors by hiding the responsibility from the programmer, this means the programmer cant make common mistakes in C++ which are de-alocating memory twice or not at all, also this stops the programmer pointing to parts of memory which are out of bounds. This makes java more simple and user firendly.
    Java has a massive class libary as standard, this library is on call for the programmer to call upon as needed, this library is packed with useful classes the progrmamer can use without having right the code himself.
    Java is everywhere
    Java is used in over 2.5billion devices these are listed below:
    700 million computers
    1 billion mobil phones
    1.25 billion smart cards
    plus set-top boxes, printers , webcams, games, lottery terminals, medical devices, parking payment stations etc.
    and I will include a summary cover the main points of what I have listed above.
    other things I might mention here and there.
    Java is less expensive than .NET and other languages to use, with Java you pay a one off lisence fee rather than such as Microsoft who charge annual subscription.
    Learning programming you may not see yourself as a programmer for consumer electronics but Java opens these doors to you.
    Java is an excellent first language for people to learn who are starting out in programming, less confusing than C/C++ but still powerful.
    =====================================================
    Thats about it, so come and get me! I was rather make a fool out of myself in a forum rather than at a seminar so I dont mind if your harsh, the presentation is in powerpoint format and the above is what I plan to say with the aide of slides, I wont be using notes, as they expect confidence and a sound knowledge of your subject. I know it would be nice to mention more about J2SE/J2EE but I dont have the knowlege at this stage, that is why I chose only the origins and benefits. BTW the speech is only ment to run for about 10 minutes.
    Thanks to anyone who took the time out to read the above and post any suggestions.
    Mike

    Java code compiles slower than C/C++ one may ask why
    would we need Java?It runs slower. No one cares about compile time.
    >
    Java code compiles not into Native code like other
    languages, this is the main reason it runs slower but
    is the same reason Java is portable and secure.
    That point needs more explaination. Security has many meanings and in some circumstances native code will be considered more secure.
    >
    Java is less expensive than .NET and other languages
    to use, with Java you pay a one off lisence fee
    rather than such as Microsoft who charge annual
    subscription.
    Not sure what you meant there.
    MS charges for the IDE. Sun charges for their IDE as well. The compiler is free from both however.

  • I need to use the PDF editor so I can sign or edit documents already on pdf format. Please advise?

    I need to use the PDF editor so I can sign or edit documents already on pdf format. Please advise?

    As per my understanding , To disable the field RV45A-KWMENG based on the condition for Transaction VA01/VA02.
    The conditions which i need to check is Order Type and item category.
    I understand that this is the code which i need to insert for disabling the field but i have a question here, where is the condition here and how the system understand for this field RV45A-KWMENG it has to disable. I think we need give the condition as if RV45A-KWMENG....... Another one if iam not wrong we need check that it has to be done in VA01 and VA02 then only this condition should be executed.
    IF VBAK-AUART EQ 'XXX' OR VBAP-PSTYV EQ TANN .
    IF SCREEN-NAME = 'XXX'.
    SCREEN-ACTIVE = 0
    ENDIF.
    ENDIF.
    Please suggest me the better way how can i do it in the coding.
    Awaiting for ur prompt reply.

  • There is a bug in FF 14,15,16 (I believe all 3) regarding mousedown x/y in an SVG canvas area. Please advise how to report this and have someone fix it.

    I am a web developer. The bug is in latest versions of FF however works fine in previous versions 6-9 (I believe), IE,Chrome. Please go to http://partybannerman.com/svg2/svg-editor.php?id=108&catid=35&wch=MXx5
    Select the number 7 with the arrow tool. Observe the location of the cursor
    Click-drag the selection and closely watch the cursor.
    The cursor no longer is in the same relative position. relative to the object selected.
    This is particularly annoying when zoomed into the "7".
    The precision is necessary for commands that we are implementing that require the cursor position relative to the object selected to be exact.
    Please advise, and thanks for your help

    Not entirely sure I follow your instructions. One thing I do note is the initial starting position of the "7" differs when I compare Firefox (17 or 10) with Chrome. Is that relevant ?
    I wonder if part of the difference may be in how differing browsers cope with the code. I am not a developer and do not know how relevant this is but I note if I try the validator http://validator.w3.org/unicorn/ it is returning some errors.
    If you do think there is a bug try to make a simple test-case that demonstrates this and post in [https://bugzilla.mozilla.org/ bugzilla]. If this appears to be a regression it would be handy to pin it down at least to a particular Firefox version, although users should not now be using Firefox 6-9. (Drill down from [https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/ here] if you need an old version of Firefox to run tests with)
    Someone more knowledgeable may provide further information, or if you need advice on troubleshooting coding issues you may find this forum useful http://forums.mozillazine.org/viewforum.php?f=25

  • Please advise on the the alternative sol

    When using the FM RZL_READ_DIR_LOCAL
    i get the list for files name in the importing directory (let's say ITAB)
    With the list of file name i need to chek whether the file name exit in table KNA1 for the field KUNNR
    I firstly thought of
    Loop at itab.
    write itab-name into L_KUNNR.
    select single kunnr
    form KNA1
    where itab-name = L_KUNNR.
    if sy-subrc EQ 0.
    *Message name is valid
    endif.
    endloop.
    Since for every time file name that exist it is accessing the database KNA1 please advise way t make it more performance
    Another alternative way is
    Loop at itab.
    write itab-name into itab_tmp-kunnr
    append itab_tmp.
    Endloop
    select xxx into KNA1
    for all entires in itab_tmp
    where kunnr = itab_tmp-kunnr.
    into i_knA1
    Loop at itab_tmp
    reat i_knA1 where i_kan1-kunnr = itab_tmp-KUNNR.
    if sy-subrc EQ 0.
    *Message name is valid
    endif.
    endloop

    Hi,
    Change code as:
    Loop at itab.
    condense  itab-name.
    itab_tmp-kunnr = itab-name.
    append itab_tmp.
    clear itab_tmp.
    Endloop
    if not itab_tmp[] is initial.
    select xxx
    into table it_KNA1
    from kna1
    for all entires in itab_tmp
    where kunnr = itab_tmp-kunnr.
    endif.
    Now all the entries present in  it_KNA1 are valid entries.

  • Export/import to clone database -- please advise

    Hi All,
    Need help especially from exports that are strong in export/import.
    can someone advise me how to use export/import to clone a database?
    I know how to clone database using cold backup and hot backup.
    But wish to know the full steps in using export/import to do cloning.
    I'm going to do a full export on my "TEST" database, drop the database, create a database and import using the full export.
    After doing a full database export, full=y. What are the steps to follow. Have a few doubts about it.
    1) export the database (full=y)
    2) drop the database
    3) re-create the database, will be using the same name "TEST".
    4) create the users (IDs created by DBA, eg: schemas), tablespace and datafiles. --> import doesn't do it right?
    5) do a full import (full=y). In this step, will i encounter any problems? As in understand that all the oracle-owned objects (example SYSTEM, SYS, AUX) are already in the newly created database, will import full=y cause any problems?
    6) do i have to re-create the roles, SYNONYMS and grant role,sys,obj privileges to IDs not created by oracle. (example schema owner)
    in short i would like to know what EXPORT will export and not export
    what IMPORT will import and not import.
    Please advise.

    Hi zetabouy,
    thanks for ur input, definately helpful for me.
    just to confirm. am i right to say that only a full database level (full=y) export/import will export/import out roles as well as public synonyms? because i have tried also exporting a user from the database, and imported that user into a different database, but public synonyms and roles were not imported.
    one more question:
    For example we are going to do port data from production to uat database using export and import for only the schema.
    After exporting from production with such syntax (owner=OWNER01),
    is is better to drop all objects beloging to the schema owner in UAT before importing it (touser=OWNER01, ignore=y) using the production dumpfile?
    I'm asking this question as I'm afraid that if we did not drop all the pl/sql objects in UAT database, the updated procedures/fuctions/triggers exported from the production database will not get imported to the UAT database as UAT database have the same procedures/fuctions/triggers names (but not updated code) .
    will profiles be exported and imported too duing full database level exp/imp?
    please kindly advise.
    thanks
    Message was edited by:
    chew

  • I run firefox on three computers and on this one my website font is not correct. All of my boxes are set up the same. Please advise.

    As I mentioned above I have three pc's all running win7 and firefox 6.02. On this box website fonts are different than the others. All of the "option" settings are identical on all of the boxes. Including "allow pages to choose their own fonts". I uninstalled 6.02 and installed 5.0 but there was no difference. So I reset to 6.02.
    The pages look fine in IE.
    Please advise.

    That change needs to be made to the CSS file that is on the web server.
    So if you use a CSS file or have the CSS code in the main HTML file then add <b>font-stretch: condensed;</b> to all CSS rules that have a ''font-family: "Arial Narrow";''
    If you do not have access to the page code and can't modify it then there is not much that you can do.
    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.
    See http://forums.mozillazine.org/viewforum.php?f=25

  • HT1926 Every time i download i tunes, it stops at 99percent with 1 second left for the installtion, it never installs completely, please advise what i should do.

    I cannot download i tunes to my new computer, everytime i try, it downloads 99% with 1 second left and it stalls, never completing the download. There is no error code or anything so please advise how to proceed.

    Temporarily disable any security software on the computer and try again.

  • 1084: Syntax error: expecting rightbrace before end of program. Please Advise

    Hi There,
    I am trying to create a page flipping motion in flash but I keep getting the above error. This is my first real attempt at anything in flash and I really dont know what I've done wrong. Could you please advise me and reply with the corrected code?
    Many thanks
    import fl.transitions.Tween;
    import fl.transitions.easing.Strong;
    import fl.transitions.TweenEvent;
    con.sidea.flip.addEventListener (MouseEvent.CLICK, onflip);
    con.sideb.flip.addEventListener (MouseEvent.CLICK, onflip);
    addEventListener ( Event.ENTER_FRAME, loop);
    var isStill:Boolean=true;
    var arraytween:Array = new Array();
    function onflip (e:Event) {
    if (isStill) {
    arraytween.push(newTween(con, 'rotationY', Strong.easeOut, con.rotationY, con.rotationY+180,1,true));
    arraytween [0] .addEventListener (TweenEvent.MOTION_FINISH, reset);
    isStill = false;
    function reset(e:Event){
    isStill=true;
    arraytween=[];
    function loop (e:Event){
    if (con.rotationY>90 && con.rotationY<=270) {
    con.addChild (con.sideb);
    con.scaleX=-1;
    } else {
    con.addChild (con.sidea);
    con.scaleX=1;
    if (con.rotationY>=360) {
    con.rotationY=0;

    Dinky624-
    You need to add } at the bottom of your script your function "loop" needs it.
    Sean

Maybe you are looking for

  • How do I find the FTP info for my site?

    I created a site with Wix.com. Since then I've been exploring Dreamweaver, and the author of "Dreamweaver for Dummies" suggets that the best way to make changes to my existing site is to use Dreamweaver's FTP capabailities to download the existing pa

  • Alternative way of Updating of Subinventory Accounts

    Hi. Issue at hand : How to update (alternative way) the subinventory accounts of FIN and STAGE? Facts : 1. Current setup includes - OM, Financials, INV ( but only to a very minimum level, having 2 Subinventories FIN and STAGE used for Order-to-Cash C

  • I'm having trouble installing Adobe Flash too....

      I can't my Adobe Flash Player to work on my Mac OS X 10.5.8.  in Safari.  I have tried everything I have read- uninstall,repair remissions, spent about 3 hours with Apple Support and still can't watch videos.  I know a lot of people are having this

  • JDBC Queue Blocked

    Hi there. There is problem that's been bugging me. We use XI 7.0. and all of patchs have been up-to-date. Queue Hanging in the Adapter engine(JDBC) occasionally happen. Like below, In 2009-01-14 13:21:59, Receiver JDBC adapter successfully processed.

  • PYTHON in HTMLDB

    I know nothing about PYTHON, so please think that you are talking to 6 year old ... my setup: APEX 2.2.1 on ORACLE 10.2.0.2 on SOLARIS 10 I would like to implement this PYTHON library (or better say 2 libraries). http://bitworking.org/projects/sparkl