HttpServer error in reading buffer size via keyboard input - HELP

I've written a simple HttpServer program that reads keyboard input to construct a buffer to copy the requested file into the socket's output stream. I've done the string-to-integer conversion using BufferedReader and parse.Int. However, when I go to use the int later in the program, I keep getting the message "variable b may not have been initialized." Can anyone tell me what's missing from the code below? Thanks.
private static void sendBytes(FileInputStream fis, OutputStream os)throws Exception
     //Construct a buffer via console input
     BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
     String str;
     int b;
          System.out.println("Enter desired buffer size or CTRL-C to break.");
     //Convert entry to an integer
     do
          str = br.readLine();
             try
               b = Integer.parseInt(str);
          catch(NumberFormatException e)
               System.out.println("Invalid entry.");
     while((str=br.readLine())!=null);
     //Construct a buffer
     byte[] buffer = new byte;
     int bytes = 0;
     //Begin timing HTML page delivery
     long start, end;
          System.out.println("Timing for Web page delivery");
     start = System.currentTimeMillis();
     //Copy requested file into the socket's output stream
          while((bytes = fis.read(buffer)) != -1)
          os.write(buffer, 0, bytes);

As the message suggests, what is missing is code to initialize the variable b. The first mention ("int b;") does not initialize it. The second mention ("b = Integer.parseInt(str);") only initializes it if no exception is thrown. So it's possible for b to be uninitialized when you actually try to use it.
What do you need to change? First you need to decide what's to be done if the keyboard input isn't a valid integer. Do you have a default value in mind? If so, put that where you declare the variable ("int b = 42;"). If not, just initialize the variable to zero ("int b = 0;").

Similar Messages

  • Reader Closes on any Keyboard input

    Has anyone had this problem?
    Reader closes on any keyboard input.
    Mouse works fine.  And I mean any keyboard action at anytime.
    I have tried uninstalling all adobe reader apps/plugins and reinstalling the latest available version but still Reader closes with any keyboard input.   Make opening password protected PDF's impossible.  The "find" function unusable.
    Any Ideas?

    Are you trying to run your application through TextPad, or some IDE? The System.in is best for command prompt input. Trying running your program through the command prompt, and it should work fine.
    I replicated your error, running your application through TextPad.

  • Error while adding a custom field with Input help via AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running  and Autopopulating seocnd field while I am testing it
    While adding second field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Secondly,not getting getter and setter methods for the attrributes in BTAdminI.
    Last,please tell me if i create zhelp and activate it,would it automatically appear in the list on AETwhile assiging it to input field?
    Please help me out.Kindly be detailed as I am new to SAP CRM.
    Thanks,
    Shivani

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

  • What is ths maximum PDO read buffer size using the Series 2 CAN cards?

    Does anyone know the maximum size for the PDO read buffer when using a Series 2 PCI NI-CAN card?

    Hi
    The maximum size for a single PDO does not depent on the series of your board it is depending on what else you are doing with the CANopen Library.
    The board uses a specific shared memory to transfer messages between driver and hardware. The size of this memory fits nearly 350 messages.
    The CANopen Config takes 100 messages for different services like NMT. That means the maximum size for a single PDO would be approx. 250 messages.
    Or for 5 different PDOs 50 each. But normaly you can leave the buffer size to zero, thus the PDO Read would allways read the newest data.
    This calculation is true for the board. That means you have 350 messages per board and 2 ports whould need to share the memory.
    DirkW

  • I just upgraded Thunderbird and now I can't send emails: error message reads "file size too large" which is not the case

    error message reads "size of message exceeds temporary size limit of server"; The message is 1 word long so that's obviously not the problem;
    I upgraded automatically to the latest version on 7-16-14 and that's when the problem started

    The size of the message you are trying to send exceeds a temporary size limit of the server. The message was not sent; try to reduce the message size or wait some time and try again. The server responded: 4.5.3 Your message has too many recipients. For more information regarding
    4.5.3 Google's sending limits, please visit:
    4.5.3 http://support.google.com/mail/bin/answer.py?answer=22839 u5sm10938190obv.10 - gsmtp.
    I get this message when attempting to send a message to my distribution list. Problem started today. Single recepients work okay.

  • FMS3 - Read buffer size

    Hello,
    I'm currently testing my custom file plugin, and I've noticed
    that FMS uses rather small
    buffer sizes when reading files (256K at most, sometimes only
    reading 1 or 2 bytes at a time).
    Is there a way to increase the buffer sizes? 1MB reads would
    be much more efficient.
    I've also noticed that every time a read takes place, the
    server opens, reads and then promptly
    closes the file after reading just one chunk, resulting in
    thousands of open/read/close cycles
    for a single session. (Very inefficient) Is there a reason
    for that behavior?
    Thanks,
    Gilad

    Of course I don't know why this happens, but given that what you expect as a message length seems not to be quite random, but rather some text in English, tells me that certain things are shifted in your buffers. Maybe the buffers are sometimes build incorrectly or read incorrectly. You see, the probability of assembling "icy-" out of 4 bytes is about 1 in 4 millions. I would assume this is a piece of text that is wrongly assumed to be the mesage length.

  • Keyboard input help!?

    What is the easiest way to get keyboard input into my application?
    Thanks!

    Do you know [url http://www.google.ca/search?hl=en&q=java+keyboard+input&btnG=Google+Search&meta=]Google? It is very helpful.
    Also you should read thoroughly the [url http://java.sun.com/docs/books/tutorial/essential/index.html]Essential Java Classes Tutorial, more specifically (related to the question): [url http://java.sun.com/docs/books/tutorial/essential/system/iostreams.html]The Standard I/O Streams Tutorial.

  • Help with ichat errors-have read recent topics but need more help

    Hi, I have searched the topics in here and have seen a lot of different answers to this, but I am not sure where to begin since they seem so complicated. I am trying to get ichat to work with a colleague and we get the -8 error. I am using a linksys 54 router. Can someone give me a simple answer as to where to begin to fix this? Thank you

    Hi,
    There is no simple answer.
    It depends on what details are in the log for your Error 8 as to where to suggest you look and change settings.
    In Broad terms Error 8 is about ports not being open or a NAT issue between you end and the other.
    1) Use UPnP in modems and routers where you can.
    2) If the Mac firewall is On set the iChat ports as there is no preset.
    3) make sure the ports are allowed in your modem and or router if you don't have UPnP
    4) do not have two devices issuing DHCP IP addresses.
    5) If the log is essentially blank after the last error 8 and the start of Binary Images the problem could be your ISP or any VoIP device you have.
    That should start you off for the next set of questions
    10:45 PM Tuesday; October 23, 2007

  • Getting error while adding a custom field (with input help) through AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running while I am testing it
    While adding fsecond field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Please help me out.Kindly be detailed as I am new to SAP CRM.

    Thanks for very helpful reply. After implementing the suggested SAP note, I am able to see the getter and setter methods.
    So one of my problem has got solved with your kind help:)
    As per your another suggestion,I have created the enhanced fields without the search help from AET in the node BTAdminI with names Plant(ZZPLANT) and Storage Location(ZZStoarge_Loc).
    Now I am facing below problem:
    Since Plant needs to autopopulated by Storage Location (search Help ZOFI_SHLP_STORAGE_LOC),So I need to Implement Getter setter method.
    I have written below code into Get_V_ZZStorage_Loc Method:
    method GET_V_ZZSTORAGE_LOC.
      DATA:
        ls_map    TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping,
        lt_inmap  TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab,
        lt_outmap TYPE if_bsp_wd_valuehelp_f4descr=>gtype_param_mapping_tab.
        ls_map-context_attr = 'ZZSTORAGE_LOC'.
        ls_map-f4_attr      = 'STORAGE_LOC'. (Storage_loc is the parameter defined in search help)
        APPEND ls_map TO: lt_inmap, lt_outmap.
      CREATE OBJECT rv_valuehelp_descriptor TYPE cl_bsp_wd_valuehelp_f4descr
        EXPORTING
          iv_help_id        = 'ZOFI_SHLP_STORAGE_LOC1'
          iv_help_id_kind   = if_bsp_wd_valuehelp_f4descr=>help_id_kind_callback
          iv_input_mapping  = lt_inmap
          iv_output_mapping = lt_outmap.
    endmethod.
    But its not working.Should I write some code in Get_P_XX or some other method also?
    Kindly suggest .

  • Illustrator CS4 Keyboard Input HELP

    Hello, I have searched these forums (as well as the interwebs) up, down, left, and right so I apologize if this has been brought up before.
    This problem began shortly after upgrading to CS4 so it never occurred in CS3.
    Anytime illustrator is opened, shortly after I lose almost all function of the keyboard.  This not only applies to illustrator but also any other programs open at the time (exe: firefox, skype).  I can only input ONE character, then, the keyboard basically becomes useless, unless i click in the window somewhere which then permits me again, only ONE character input.
    This has rendered my shortcuts in illustrator, any numeric entries, and any control+keys useless.  The only fix, is closing illustrator, reopening, and using again for 5-10mins before the keyboard fails again.
    If i jump into another program (with illustrator open), like firefox for instance and try to start typing a URL, the first letter i type works fine, but each subsequent letter i type in simply replaces the first one (the letter highlights itself like if i clicked and dragged over the letter, then the new letter just replaces that).
    Another issue with the keyboard, is that sometimes when i start to enter characters, it will jump to another program I have open, for instance, illustrator, firefox, and skype are open.  Start to type in the skype chat box, and all of a sudden firefox jumps to the front.
    Also, if open up CS3 illustrator, that same problem now occurs, however it never occurred prior to CS4.
    Vista 64 SP1
    Sager Np2096 notebook
    Intel Core 2duo P9500
    Please let me know any additional information i can add to help, this is a new world to me!
    This cannot keep going on.
    desperate, please help,
    thanks!

    I had a similar problem with my mouse until I replaced it.  There was something awry with the cable connecting the mouse to the computer.  Since you say you have replicated the problem across various OS's and various keyboards, not sure where to direct you other than your computer manufacturer.  It can't be a CS4 issue because you're experiencing the same problem with Firefox and Skype, right?

  • MPEG Streamclip 1.8  error message "can't read frame size"

    I receive message "Error: cant read frame size" after importing a QuickTime Movie file into MPEG Streamclip and choosing File-> Export to QuickTime as suggested in another forum to resolve the problem of no sound when importing a still camera QuickTime Movie file like the following into iMovie.
    (MPEG Streamclip imports the sound but no video.)
    Bottom line, how do I get the video and sound together in iMovie or Final Cut Express?
    Stream: Louie&Sarful 3345.mov
    Path: ~/Movies/Sarful & Louie/Louie&Sarful 3345.mov
    Type: MPEG elementary stream
    Duration: 0:00:53
    Data Size: 0.49 MB
    Bit Rate: 0.08 Mbps
    Video Tracks:
    DV/DVCPRO - NTSC, 720 × 480, 29.97 fps, 28.77 Mbps
    Audio Tracks:
    192 MP2 mono, 32 kHz, 64 kbps
    Stream Files:
    Louie&Sarful 3345.mov (2.13 MB)
    I'm trying to resolve the problem of no sound when importing/opening still camera movie files like this into iMovie or Final Cut Express.
    iMac5,1 IC2D   Mac OS X (10.4.8)   1 GB 2.16 GHZ

    Ref Bottom Line
    Solved my problem by opening the file in MPEG Streamclip and choosing Demux to AIFF and saving the AIFF file to the same folder as the original, then drag the AIFF file to the sound track in iMovie and the original file to the video track.
    iMac5,1 IC2D   Mac OS X (10.4.8)   1 GB 2.16 GHZ

  • Doing Buffered Event count by using Count Buffered Edges.vi, what is the max buffer size allowed?

    I'm currently using Count Buffered Edges.vi to do Buffered Event count with the following settings,
    Source : Internal timebase, 100Khz, 10usec for each count
    gate : use the function generator to send in a 50Hz signal(for testing purpose only). Period of 0.02sec
    the max internal buffer size that i can allocate is only about 100~300. Whenever i change both the internal buffer size and counts to read to a higher value, this vi don't seem to function well. I need to have a buffer size of at least 2000.
    1. is it possible to have a buffer size of 2000? what is the problem causing the wrong counter value?
    2. also note that the size of max internal buffer varies w
    ith the frequency of signal sent to the gate, why is this so? eg: buffer size get smaller as frequency decrease.
    3. i'll get funny response and counter value when both the internal buffer size and counts to read are not set to the same. Why is this so? is it a must to set both value the same?
    thks and best regards
    lyn

    Hi,
    I have tried the same example, and used a 100Hz signal on the gate. I increased the buffer size to 2000 and I did not get any errors. The buffer size does not get smaller when increasing the frequency of the gate signal; simply, the number of counts gets smaller when the gate frequency becomes larger. The buffer size must be able to contain the number of counts you want to read, otherwise, the VI might not function correctly.
    Regards,
    RamziH.

  • Will increasing the buffer size make flash streaming video stop stalling?

    I have surmised all this on my own so it could be just a fantasy, but:
    I am often the victim of slow internet connections. This means that when I try and watch streaming video it constantly pauses. It's my understanding that increasing the buffer size of flash would help prevent this but I can't figure out how to do that.
    Thanks

    You can pause the video just long enough for the player to load enough content. Most Flash player show a loading bar if you hover the player. For short pieces you can load the entire content before starting the play.

  • O/S read block size.

    Need to set few Oracle parameters based on solaris read buffer size.
    Experts out there can any one pass on the links and or documents as well how to check in the system?
    Knowing this would enable me to tune the system and improve the system I/O.
    My env is Solaris v5.10 ~ 64 bit system .

    I thought some one would give their valuable points!!!!!
    I could read it as 64KB in some documents?
    Is that right?
    Can this be configured?

  • Input Help for Read Only Inputfield

    I have a requirement where an inputfield should be grayed-out so the user can't simply type whatever they want into the field.  However, the user should still be able to change the value of the inputfield via the input help (F4).  After searching around in the forums, I see that the only way to do this is to use a custom input help (as opposed to DDIC or OVS).  I've done that, and it works fine when the inputfield is open.  However, as soon as I set the inputfield to "Read Only", the input help button goes away.
    How do I get the input help button to stay even though the field is set to "Read Only"?
    Thanks,
    Tom Peng

    Hi,
    I have a requirement where an inputfield should be grayed-out so the user can't simply type whatever they want into the field.
    If the user shouldnot  enter the data what ever he wants in input field ,you can use foreign key check ,
    So that it throws an error message, when use enters the data   other than the values in F4 help.
    So  with out making  the field  read only  you can solve the problem.
    Priya

Maybe you are looking for

  • Selecting items in a list from a multivalue field

    I have an edit page that includes a menu form element that allows multiple selections. It inserts all the IDs from a table that it's got from a recordset as a string into field named EventType separated by commas ("10000,10002,10004"). So far so good

  • FI drilldown reports- cant get Line item details in dynamic selection

    Hi, In FI drill down reports line item analysis, i create form in FDI4.I get document currency as a key figure. While executing a report in tcode FDI0. i gave company code,dealer and currency as 'EUR' in dynamic selection,. the correct output value '

  • W530 wake-up issues

    Often times when I close my laptop lid for a while (20-30 min or more) and I open it back up, the light around my power button flashes on and off and I see the hard drive indicator light flashing as though its working but it doesn't come back on. I'm

  • HTTP4044 error - did not produce a valid header ??

    Occasionally when someone is uploading a file to our web server, we are getting this response. It doesn't happen all the time. It is receiving uploads all the time. Has anybody seen this or know what may be causing this problem? failure (12172): for

  • Selecting Column Names

    Hi, I'm using Forms6i. I have a table 'Call_header' with columns 'CallID', 'Attach1','Attach2' and 'Attach3'. and in my form,i've a control block with 2 text fields, one for Callid and the otherone for which i need to show lov from 'Call_Header'. Sup