How could I write this in java

I have to use a parameter in a statement. I am trying but its giving error. I am trying to write it like ....
fw.write("Object     dir/my.dat\n");I substitute my.dat with a variable dat & write like
fw.write("Object     dir/+"dat"+\n");dat is a String variable.

Sam_Fin wrote:
thanks,welcome
How could I remove this error.
Unreported exception java.io.IOException; must be caught or declared to be thrown fw.write("#the number of patterns to be recognized\n");
Its for every fw.write statement.read the Sun (Oracle?) [tutorial on exceptions,|http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html] and then either throw the exception or wrap in a try / catch block (the tutorial will explain how).

Similar Messages

  • How could u write this application?

    write an application to read an unknown number of integer pairs representing binary numbers from a file redirected input from the command line. do not use sentinel value or prompt.
    1. Echo print in colums 1 and 2 the numbers that were read.
    2. Convert each number to decimal for columns 3 and 4.
    3. Count the number of 1's in the numbers for columns 5 and 6.
    4. Find the larger of the decimal versions of the first and second number of each integer pair, and print that number in column 7.
    5. Keep separate cumulative sum of the decimal versions of the first and second number of each integer pair, and print that number below the appropriate column after all numbers have been read.
    Sample output:
    10 11 101 1111 111 10000 101011 0
    thanks for your interest

    > hey young fella, its not a HW or something!! everyone
    talks alot here like they know everthing(which they
    aint gotta clue), i decided to put an easy
    application to c how many people are going to be able
    to write this application??
    That's a little tough to believe. It's far more likely that you need some help on figuring out how to go about writing such an application. There's nothing wrong with that; just know that most folks who volunteer to help here aren't particularly interested in "proving their skills" by way of programming "challenges". They typically get far more satisfaction by helping others learn Java.
    i guess u r one those fellas who dont have a clue about java!!! b/c if u
    were not, this would take ur 5-6 mins of time..
    So, do you have a specific question regarding those requirements? If you do, please ask. If, on the off chance you've got some special insight regarding an implementation, post your idea and get some feedback from the community.
    Also, please make the extra effort to write out words such as "see", "you", "are", "your", and "because". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership. Also, it will give the appearance that you take your question seriously, which will in turn make your question look more interesting to answer.
    Thanks!
    ~

  • How could I write this code?

    I am trying to create a shared object that will host a chat
    room environment. I will have many of these rooms and I know what I
    want to do, just not how to write it in actionscript or if it is
    even possible. the underlined portion is what i just don't know how
    to code (
    (room + roomNumber + _so) ) as it should throught usage
    equate to something like
    room1_so,
    room2_so,
    room3_so, and so on. any help would be greatly appreciated.
    thanks in advance.
    function doJoin(roomNumber) {
    (room + roomNumber + _so) = SharedObject.getRemote(
    (room + roomNumber + _so) ,_root.clientroom_nc.uri,true);
    if(
    (room + roomNumber + _so) ).data.seat1 = occupied) {
    do this;
    }

    its actually connecting to flash media server remote shared
    object as opposed to the local shared object. The code in question
    was actually taken nearly word for word from the macromedia sample
    file so I know that that portion is correct.
    If I replace the shared object name from
    tl["room"+roomNumber+"_so"].connect(_root.clientroom_nc);
    and change it to
    room1_so.connect(_root.clientroom_nc);
    everything works fine and the connection is succesful,
    however since I hope to have many many rooms that is just not a
    feasible way to write it. I have racked my brain trying to think of
    an alternative way of writing it but have come up with nothing. I
    am well versed in Basic, PHP, and some C, but this damn
    actionscript stuff is throwing me for a loop since it is incredibly
    different in a lot of ways.

  • List v = new Vector() how can i write this ?

    List v = new Vector() how can i write this ?
    vector does not 'extends' List rather it 'implements' only ......so how can write this way ? ( polymorphism applies only for 'extends' ).

    my question in a simple way is :
    List some_list extends Vector
    No, List is an interface; Vector is a concrete class. Read the javadocs.
    Vector implements List
    >
    AND
    List some_list implements Vector
    are these two same in behaviour
    our  apart from theoretical differences ?thanks
    Interfaces don't have any implementation; they're pure method signatures. When a concrete class implements an interface, it makes a promise that says "I will provide implementations for exactly these methods. Any client can call a method from the interface and I will do something 'sensible' if I'm written correctly."
    From the point of view of static and dynamic types, there's no difference between interfaces and classes.
    C++ has interfaces, too - they're classes with all pure virtual methods. If you understand how C++ works, the concept shouldn't be hard.
    ArrayList is preferred precisely because it isn't synchronized by default. (You can always make it so using java.util.Collections if you wish later on.) If you don't need synchronization, why pay the performance penalty?

  • HT1926 when trying to setup itunes on my pc i get the following message: there is a problem with this Windows installer package. A program required for this install to complete could not be run. How could I solve this problem?

    when trying to setup itunes on my pc i get the following message: there is a problem with this Windows installer package. A program required for this install to complete could not be run. How could I solve this problem?

    Repair your Apple software update.
    Go to START/ALL PROGRAMS/Apple Software Update. If it offers you a newer version of Apple Software Update, do it but Deselect any other software offered at the same time. Once done, try another iTunes install
    If you don't find ASU, go to Control Panel:
    START/CONTROL PANEL/Programs n Features/highlight ASU and click REPAIR,

  • Hi, I upgraded my iphone 4 to iso 5 beta 6, but now it shows "No Service" at top left, and unable to complete your activation. Also tels that this device is not registered as part of the iphone developer programme. How could I fix this problem? Please..?

    Hi, I upgraded my iphone 4 (4.3.3) to iso 5 beta 6, but now it shows "No Service" at top left, and unable to complete your activation. Also tells that "this device is not registered as part of the iphone developer programme." How could I fix this problem? Please help me...,

    I had a similar occurrence with my just activated iPhone 4.
    I had been using the phone for three days when an odd occurrence with voice mail caused me to call tech support. After some discussion they decided to push the activation to my phone (even though I had been using it for three days). When I went to power it back up again I repeatedly got the "no service" notification. I got tech support on a land line and we tried hard reboots and so on. No joy. They told me to take it in to the point of sale and either the SIM card or the phone needed (or both) needed replacing.
    I tried one last hard reboot after dinner and the phone came up with service, but I took it in to the point of sale in the morning and they swapped the SIM card out and I went to a Genius Bar appointment to get the phone checked out. It is supposedly OK, but I am still having some problems when syncing it so I will have to visit the Genius Bar again tomorrow about that. At least I have not experienced the "no service" problem in the roughly 24 hours since the SIM card was replaced. (Fingers crossed)

  • How do I write this SQL command in Oracle

    Hi all
    I wriote this SQ L statement in Ms SQL Server. How do I write this sql command in Oracle?
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    I am very interested in this part:
    SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007
    thanks
    Edited by: user631364 on Oct 27, 2008 8:25 AM
    Edited by: user631364 on Oct 27, 2008 8:26 AM
    Edited by: user631364 on Oct 27, 2008 8:27 AM

    Thank you!!
    Now let me aslk the second part of my question.
    This sql command:
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    was created with this query in SQL Server and then I saved it in a store procedure, that I scheduled to run montlhy
    SET ANSI_NULLS ON
    DECLARE @SQLString NVARCHAR(4000)
    /* Build the SQL string once.*/
    SET @SQLString = 'ALTER VIEW dbo.Consumption AS SELECT TOP 100 PERCENT ID, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 12) +
    "'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 12) +
    … (GOES FROM current month -12 to current month -1)
    , CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 1) +"'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 1) +
    ' FROM dbo.MasterConsumption WHERE YEAR_MONTH >= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-12 ) +"'" +
    ' AND YEAR_MONTH <= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-1 ) +"'" +
    ' GROUP BY ID ORDER BY ID '
    EXEC sp_executesql @SQLString
    Is that something that can be done in Oracle in the same way?
    Do you use another approach?
    please advice
    Edited by: user631364 on Oct 27, 2008 10:19 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:22 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:24 AM

  • How do I write this as a loop?

    How do I write this code to function as follows.
    When btn1 is clicked, SenderLoad should be "clay" AND when btn2 is clicked, SenderLoad should be "iron", etc...
    var mgB:Array = [btn1, btn2, btn3, btn4];
    var mgBW:Array = ["clay", "iron", "cotton", "leather"];
    var SenderLoad:LoadVars = new LoadVars();
    var ReceLoad:LoadVars = new LoadVars();
    var mgNum:Number=0;
    for (i=0; i<mgBW.length ; i++){
    mgBW[i].onRelease = function () {
    mgNum++
    SenderLoad.word = mgB[mgNum];
    SenderLoad.sendAndLoad("http://www.web.com/my.php",ReceLoad,"POST");
    ReceLoad.onData = function(src) {
    var messageA:Array = src.split(",,,");
    ldrB2.html=true;
    for(var i:Number=0; i<messageA.length; i++){
               var a:Array=messageA[i].split(",,");
       ldrB1.htmlText +=a[0];
       ldrB2.htmlText +=a[1];

    if you want different words in different colors you can use:
    ldrB1.html=true;
    ldrB1.text = formatF("REJECT",0xff0000,ldrB1)
    ldrB1.text = formatF("ACCEPT",0x000000,ldrB1);
    ldrB1.text = "formatF("BANNED",0xc0c0c0,ldrB1);
    function formatF(s:String, col:Number, tf:TextField):Void {
    if(tf.text.indexOf(s)==-1){
    return;
        tfor.color = col;
        var startindex:Number = 0;
        while (startindex>-1 && startindex<tf.text.length-1) {
            var bindex:Number = tf.text.indexOf(s, startindex);
            var eindex:Number = bindex+s.length;
            tf.setTextFormat(bindex,eindex,tfor);
            startindex = eindex;
    var tfor:TextFormat = new TextFormat();

  • How could I fix this code

    Hii 2 all
    How could I change this statement for parameters list,, so the client_name can contain spaces ??
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, '''' || :cntrl.client_name || '''');
    cause it couldn't print and give syntax error when the :cntrl.client_name contains any spaces !!!!
    please help
    thanks:)

    First I must apologize, I asked you to test something that was not needed... for a moment I thought we were talking about web.show_document, that's why I asked you to test with double-quotes..
    Regarding your problem, Manu is right, there is not need to wrap around the parameter in quotes..
    add_parameter(p_id,'p_client_name',TEXT_PARAMETER, :cntrl.client_name);I have to ask you the same question that Manu asked you before, where are you using this parameter?
    In your Report you must be using in a piece of PL/SQL code, we need you to post that code...
    Edited by: Rodolfo Ferrari on Sep 10, 2009 4:44 PM

  • I'd like to transfer the photos from iPhone to MacBook Air. My iPhoto used to detect my iPhone automatically, but it doesn't happen anymore. How could I fox this? Thanks for helping!

    I'd like to transfer the photos from iPhone to MacBook Air. My iPhoto used to detect my iPhone automatically, but it doesn't happen anymore. How could I fox this? Thanks for helping!

    Check the iPhoto preferences:
    From the main menu bar:  iPhoto > Preferences > General:
         "Connecting camera opens"  : Set this option to  "iPhoto".
    If that does not help, disconnect your iPhone and reset your iPhone.
    To reset iPhone, press and hold the Sleep/Wake button and the Home button at the same time for at least 10 seconds, until the Apple logo appears.

  • My QuickTime player us not playing .avi files and says I need a codec I can't play no .avi files on QuickTime. How could I fix this because I want to play these files with QuickTime.

    My QuickTime player us not playing .avi files and says I need a codec I can't play no .avi files on QuickTime. How could I fix this because I want to play these files with QuickTime.

    Hmm . . . comes with a Utility MPEG2 Component ML app with no explanation of what it's for?
    The utility app is an "assistant PKG installer." It allows Lion and Mountain Lion users to install the older QT MPEG-2 Playback Component installer PKG file which is not allowed to run on its own under Lion or Mountain Lion since these operating systems already have a QT X only MPEG-2 component embedded in the QT embedded structure. Without this utility you would have to either copy the component from an older system to your Lion or Mountain Lion system, use Pacifist for installation, or manually open the PKG contents and transfer the component to the appropriate component folder.
    As to your "discussion" regarding the playback of AVI file types, there are really only two strategies here:
    1) You can add component support so that QT can play the files natively or
    2) You can convert the file contents to compression formats that are natively compatible with the unmodified QT component configuration.
    Each user should decide for his or her own self which approach best suits their needs for a particular source file. In most cases, conforming the system's codec component configuration to play the source file directly results in higher video quality since no transcoding takes place but this strategy will not work if a codec which is required is not available for the user's operating system. On the other hand, converter utilities tend to support more built-in codecs and are easier to use since the user does not have to concern him or herself with the nature of the particular source compression formats but at the risk of some potential loss in visual quality. As to what converter to use, once again this is a matter of personal choice. In the case of commercial converters like iSkysoft, the codecs are built in while MPEG Streamclip accesses the host operating system's QT codec component configuration. I personally prefer the free HandBrake app for AVI, MKV, TS, MTS, and M2TS conversions since it has an exceptionally full-featured X.264 GUI with some user options that 97% of users are likely to never use.

  • How could we do this without killing the system?

    If we take in a file through the PI file adapter that has 1 million lines and read it in and process each line as a single transactionu2026  How could we do this without killing the system?

    Hi,
    >>>How could we do this without killing the system?
    which system ? PI could do this if the transactions are small (only one line so very small I guess)
    but I'm not sure about the ERP...
    Regards,
    Michal Krawczyk

  • How can i write this C-Code in G-Code

    hallo
    how can I write this C-Code in LabVIew ,
    for a=0; a=<10; a++
       for b=0; b=5 ; b+2
            X= 3+b;
      Y=1+a;
    please see the attachment and tell me where is the problem
    Attachments:
    Unbenannt 11.vi ‏43 KB

    Well, at least you tried and got some of it right.
    I think this should do what you want, but my C is rusty. Is the increment performed before or after the loop executes? If it's after, then I believe the loop should iterate 11 times, not 10.
    In any case, you should note that for a literal translation, you would need to add a sequence structure to guarantee that Y was written to only after the inner loop finished because of the way data-flow works.. Also, note that controls and indicators in LabVIEW are not equivalent to variables. They can be used as such, but they usually should not be.
    Another point about this is that you probably want to use the correct data type - the orange terminals are floating point indicators (of double precision, in this case) and you want integers.
    To learn more about LabVIEW, I suggest you try looking at some of these tutorials.
    Try to take over the world!
    Attachments:
    C.png ‏4 KB

  • I don't know the owner I found an iPhone4 how could I use this???

    i don't know the owner how could I use this???

    If you found a phone you should take it to the police. You don't have the right to hang onto it. If it's not claimed after a period then you may be able to retain it. But in any case if it is 'Activation Locked' only the original owner can unlock it. There is no way round this, and without being able to contact him (and if you could you should return it) the phone is permanently unusable if locked in this way.

  • My speaker doesn't work... I haven't drop it or got it wet. How could I fix this??

    My speaker doesn't work... I haven't drop it or got it wet.
    How could I fix this??

    First thing to try is to reset your device. Press and hold the Home and Sleep buttons simultaneously ignoring the red slider should one appear until the Apple logo appears. Let go of the buttons and let the device restart. See if that fixes your problem.

Maybe you are looking for