Please help me with the homework given to me by my teacher

hello,i am new in java programming please help me with the home work given to me by my teacher at school, help me to build an interface that can work with this code.i can build an interface but i dont just understand this code.
//references:
//http://forums.techguy.org/development/570048-need-write-java-program-convert.html
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
public class Translate
  public static void main(String [] args) throws IOException
    if (args.length != 2)
      System.err.println("usage: Translate wordmapfile textfile");
      System.exit(1);
    try
      HashMap words = ReadHashMapFromFile(args[0]);
      System.out.println(ProcessFile(words, args[1]));
catch (Exception e)
      e.printStackTrace();
  // static helper methods
   * Reads a file into a HashMap. The file should contain lines of the format
   *    "key\tvalue\n"
   * @returns a hashmap of the given file
  @SuppressWarnings("unchecked")
  private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
      in = new BufferedReader(new FileReader(filename));
      String line;
      map = new HashMap();
      while ((line = in.readLine()) != null)
        String[] fields = line.split("\\t", 2);
        if (fields.length != 2) continue; //just ignore "invalid" lines
        map.put(fields[0], fields[1]);
finally
      if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
   * Process the given file
   * @returns String contains the whole file.
  private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException {
    BufferedReader in = null;
    StringBuffer out = null;
    try {
      in = new BufferedReader(new FileReader(filename));
      out = new StringBuffer();
      String line = null;
      while( (line=in.readLine()) != null ) {
        out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    } finally {
      if(in!=null) in.close(); //may throw IOException
    return out.toString();
   * Replaces all occurrences in text of each key in words with it's value.
   * @returns String
  private static String SearchAndReplaceWordsInText(Map words, String text) {
    Iterator it = words.keySet().iterator();
    while( it.hasNext() ) {
      String key = (String)it.next();
      text = text.replaceAll("\\b"+key+"\\b", (String)words.get(key));
    return text;
   * @returns: s with the first letter capitalized
  String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
}... here's the head of my pirate_words_map.txt
hello     ahoy
hi     yo-ho-ho
pardon me     avast
excuse me     arrr
yes     aye
my     me
friend     me bucko
sir     matey
madam     proud beauty
miss     comely wench
stranger     scurvy dog
officer     foul blaggart
where     whar
is     be
are     be
am     be
the     th'
you     ye
your     yer
tell     be tellin'

Heres your answer. Run it in on your pc.
public class Annoy
public static void main(String[] args)
   System.out.println("I am a triple poster.");
   System.out.println("I can not understand why I can not understand the help I have receved to date on the java forums.");
}

Similar Messages

  • Please help me with the installation process.

    i have got free norton antivirus activation keybwith the pirchase of hp 16 gb pendrive .
    please help me with the installation process.

    Hey @10p,
    Welcome to the HP Support Forums!
    I understand that you need assistance with the installation of Norton Antivirus that you received with the purchase of an HP 16gb Pendrive. Did you get the Pendrive with a computer or just purchase the Pendrive on its own?
    Once I know if the Pendrive came with the purchase of a computer I will be able to point you in the right direction for support. Good luck!
    X-23
    I work on behalf of HP
    Please click "Accept as Solution" if you feel my post solved your issue, it will help others find the solution.
    Click the "Kudos, Thumbs Up" on the right to say "Thanks" for helping!

  • Please help me with the digital signature validation problem?

    Please help me with the digital signature validation problem?

    Hi
    Execute the program in the Debuggin mode.
    In the Debugger Window
    Select Breakpoint -> Break point at -> Breakpoint at source code Menu Item and enter the details of the program/include/line no..
    Activate the System Debugger On from the Settings Menu.
    Hope this would help you.
    Murthy
    Edited by: Kalyanam Seetha Rama Murthy on Jul 18, 2008 7:20 AM

  • Please help me with the accounting records of iTunes. At step in placing credit card details are asked to contact iTunes Support

    Please help me with the accounting records of iTunes. At step in placing credit card details are asked to contact iTunes Support

    Brenda, the easiest way to contact the support team is thru the iTunes Customer Service website:
    http://www.apple.com/support/itunes/contact/

  • Please help me with the step by step instructions on how to install a Windows server 2008 on a computer that has Windows 8 installed on it

    Please help me with the step by step instructions on how to install a Windows server 2008 on a computer that has Windows 8 installed on it without formatting windows 8.Please email the steps , Thanks

    Please help me with the step by step instructions on how to install a Windows server 2008 on a computer that has Windows 8 installed on it without formatting windows 8.Please email the steps , Thanks
    Assuming your rig can support virtual machines, you can use Hyper-V and run another OS there.
    Better practice however is to use a dedicated machine and use remote desktop to the server.
    Corsair Carbide 300R with window
    Corsair TX850V2 70A@12V
    Asus M5A99FX PRO R2.0 CFX/SLI
    AMD Phenom II 965 C3 Black Edition @ 4.0 GHz
    G.SKILL RipjawsX DDR3-2133 8 GB
    EVGA GTX 6600 Ti FTW Signature 2(Gk104 Kepler)
    Asus PA238QR IPS LED HDMI DP 1080p
    ST2000DM001 & Windows 8.1 Enterprise x64
    Microsoft Wireless Desktop 2000
    Wacom Bamboo CHT470M
    Place your rig specifics into your signature like I have, makes it 100x easier to understand!
    Hardcore Games Legendary is the Only Way to Play!

  • HT1338 Could you please help me with the problem. I have mac os 10.7.4 on my macbook pro retina and want to update it to 10.7.5. I had been waiting for 2 hours to do it, but then it appeared that it was impossible. What should I do?

    Could you please help me with the problem. I have macbook with retina with mac os 10.7.4 ann want to update it to mac os 10.7.5. I had been waiting for 2 hours to do it and had tried 3 times but it appeared that it was impossible. What should I do?

    You can download the standalone updates:
    OS X Lion Update 10.7.5 (Client Combo)
    OS X Lion 10.7.5 Supplemental Update

  • How to change a prospect status to customer in BP,when the prospect turns out to be a potential customer?Please help me with the details.

    How to change a prospect status to customer in BP,when the prospect turns out to be a potential customer?Please help me with the details.
    Moderation: Kindly search before you post

    Dear Ramesh,
    Using Account life cycle we can record the different stages of a BP.
    But at any point of time we can hold one Stage at Business partner.and once we change status Prospect ro Customer. We can't able to see Prospect Status in that BP.
    Ex -
    Stage A- Potentail
    Stage B- Prospect
    Stage C- Customer
    with the help of UI configuration we can define.
    Need your comment,
    Thx
    Karthik

  • Please help me with the proper query for the below problem

    Hi,
    I have a table RATE which have two columns RT_DATE (date) and RATES(number).
    This table have following data.
    RT_DATE
    RATES
    1-JAN-2007
    7
    2-MAR-2008
    7.25
    5-JAN-2009
    8
    8-NOV-2009
    8.5
    9-JUN-2010
    9
    I wanted to get the rate of interest on 8-DEC-2009.
    Output will be 8.5 as this given date is in between 8-NOV-2009 and 9-JUN-2010. Could you please help me with proper query?
    Regards,
    Aparna S

    Hi,
    That sounds like a job for the LAST function:
    SELECT  MIN (rates) KEEP (DENSE_RANK LAST ORDER BY rt_date) AS eff_rate
    FROM    rate
    WHERE   rt_date < 1 + DATE '2009-12-08'
    MIN above means that, in case of a tie (that is, 2 or more rows with the exact same latest rt_date) the lowest rates from that latest rt_date will be returned.  In rt_date is unique, then it doesn't matter if you use MIN or MAX, but syntax demands that you use some aggregate function there.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for your sample data, and also post the results you want from that data.
    Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002#9362002

  • Please help me with the logic

    Hi All,
    I have a number on the selection-screen.I need to prepare a structure with fields equal to the number provided on the selection screen.please help me with it.
    Thanks in advance,
    kushagra sharma

    Hi Kushagra,
    Below is one way of doing it.
    First create a dynamic internal table, taking number of fields from selection screen using cl_alv_table_create=>create_dynamic_table.
    Then create a dynamic structure for that dynamic internal table.
    Ex:
    DATA:fcat_wa TYPE lvc_s_fcat,
         fcat_itab TYPE lvc_t_fcat,
         poi_itab TYPE REF TO data,
         poi_itab1 TYPE REF TO data,
         cha(4) TYPE c.
    FIELD-SYMBOLS: <itab> TYPE STANDARD TABLE,
                   <wa> TYPE ANY.
    PARAMETERS: p_num TYPE i.  " Number of fields
    DO p_num TIMES.
      cha = sy-index.
      CONCATENATE 'F' cha INTO cha.
      CONDENSE cha NO-GAPS.
      fcat_wa-fieldname = cha.
      fcat_wa-datatype = 'STRG'.
      APPEND fcat_wa TO fcat_itab.
    ENDDO.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
      EXPORTING
        it_fieldcatalog           = fcat_itab
      IMPORTING
        ep_table                  = poi_itab
      EXCEPTIONS
        generate_subpool_dir_full = 1
        OTHERS                    = 2.
    ASSIGN poi_itab->* TO <itab>.  " Dynamic internal table
    CREATE DATA poi_itab1 LIKE LINE OF <itab>.
    ASSIGN poi_itab1->* TO <wa>.  " Dynamic structure
    Hope it helps u.
    Thanks,
    Edited by: Sap Fan on Oct 28, 2009 3:41 PM

  • Please help me with the following two questions, very urgent

    Hi All,
    Please help me with some scenerios about what are the common problems when modifying a standard script such a standard Invoice script and how can we overcome them.
    What are the common problems encountered when working with SAP SMARTFORMS and how to overcome them?
    Please help me with these questions, its very urgent.
    Thanks in advance.
    MD.

    hi
    hope it will help you.
    reward if ehlp.
    How to create a New smartfrom, it is having step by step procedure
    http://sap.niraj.tripod.com/id67.html
    step by step good ex link is....
    http://smoschid.tripod.com/How_to_do_things_in_SAP/How_To_Build_SMARTFORMS/How_To_Build_SMARTFORMS.html
    Here is the procedure
    1. Create a new smartforms
    Transaction code SMARTFORMS
    Create new smartforms call ZSMART
    2. Define looping process for internal table
    Pages and windows
    First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
    Here, you can specify your title and page numbering
    &SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
    Main windows -> TABLE -> DATA
    In the Loop section, tick Internal table and fill in
    ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2
    3. Define table in smartforms
    Global settings :
    Form interface
    Variable name Type assignment Reference type
    ITAB1 TYPE Table Structure
    Global definitions
    Variable name Type assignment Reference type
    ITAB2 TYPE Table Structure
    4. To display the data in the form
    Make used of the Table Painter and declare the Line Type in Tabstrips Table
    e.g. HD_GEN for printing header details,
    IT_GEN for printing data details.
    You have to specify the Line Type in your Text elements in the Tabstrips Output options.
    Tick the New Line and specify the Line Type for outputting the data.
    Declare your output fields in Text elements
    Tabstrips - Output Options
    For different fonts use this Style : IDWTCERTSTYLE
    For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&
    5. Calling SMARTFORMS from your ABAP program
    REPORT ZSMARTFORM.
    Calling SMARTFORMS from your ABAP program.
    Collecting all the table data in your program, and pass once to SMARTFORMS
    SMARTFORMS
    Declare your table type in :-
    Global Settings -> Form Interface
    Global Definintions -> Global Data
    Main Window -> Table -> DATA
    Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
    http://sapr3.tripod.com
    TABLES: MKPF.
    DATA: FM_NAME TYPE RS38L_FNAM.
    DATA: BEGIN OF INT_MKPF OCCURS 0.
    INCLUDE STRUCTURE MKPF.
    DATA: END OF INT_MKPF.
    SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
    SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
    MOVE-CORRESPONDING MKPF TO INT_MKPF.
    APPEND INT_MKPF.
    ENDSELECT.
    At the end of your program.
    Passing data to SMARTFORMS
    call function 'SSF_FUNCTION_MODULE_NAME'
    exporting
    formname = 'ZSMARTFORM'
    VARIANT = ' '
    DIRECT_CALL = ' '
    IMPORTING
    FM_NAME = FM_NAME
    EXCEPTIONS
    NO_FORM = 1
    NO_FUNCTION_MODULE = 2
    OTHERS = 3.
    if sy-subrc <> 0.
    WRITE: / 'ERROR 1'.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function FM_NAME
    EXPORTING
    ARCHIVE_INDEX =
    ARCHIVE_INDEX_TAB =
    ARCHIVE_PARAMETERS =
    CONTROL_PARAMETERS =
    MAIL_APPL_OBJ =
    MAIL_RECIPIENT =
    MAIL_SENDER =
    OUTPUT_OPTIONS =
    USER_SETTINGS = 'X'
    IMPORTING
    DOCUMENT_OUTPUT_INFO =
    JOB_OUTPUT_INFO =
    JOB_OUTPUT_OPTIONS =
    TABLES
    GS_MKPF = INT_MKPF
    EXCEPTIONS
    FORMATTING_ERROR = 1
    INTERNAL_ERROR = 2
    SEND_ERROR = 3
    USER_CANCELED = 4
    OTHERS = 5.
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Smartform
    you can check this link here you can see the steps and you can do it the same by looking at it..
    http://smoschid.tripod.com/How_to_do_things_in_SAP/How_To_Build_SMARTFORMS/How_To_Build_SMARTFORMS.html
    SMARTFORMS STEPS.
    1. In Tcode se11 Create a structure(struct) same like the Internal table that you are going to use in your report.
    2. Create Table type(t_struct) of stracture in se11.
    3. In your program declare Internal table(Itab) type table of structure(struct).
    4. Define work area(wa) like line of internal table.
    5. Open Tcode Smartforms
    6. In form Global setting , forminterface Import parameter define Internal table(Itab) like table type of stracture(t_struct).
    7. In form Global setting , Global definitions , in Global data define Work area(wa) like type stracture(struct).
    8. In form pages and window, create Page node by default Page1 is available.
    9. In page node you can create numbers of secondary window. But in form there is only one Main window.
    10. By right click on page you can create windows or Go to Edit, Node, Create.
    11. After creating the window right click on window create table for displaying the data that you are passing through internal table.
    12. In the table Data parameter, loop internal internal table (Itab) into work area(wa).
    13. In table there are three areas Header, Main Area, Footer.
    14. Right click on the Main area create table line by default line type1 is there select it.
    15. Divide line into cells according to your need then for each cell create Text node.
    16. In text node general attribute. Write down fields of your work area(wa) or write any thing you want to display.
    17. Save form and activate it.
    18. Then go to Environment, function module name, there you get the name of function module copy it.
    19. In your program call the function module that you have copied from your form.
    20. In your program in exporting parameter of function pass the internal table(itab).
    SAP Smart Forms is introduced in SAP Basis Release 4.6C as the tool for creating and maintaining forms.
    SAP Smart Forms allow you to execute simple modifications to the form and in the form logic by using simple graphical tools; in 90% of all cases, this won't include any programming effort. Thus, a power user without any programming knowledge can
    configure forms with data from an SAP System for the relevant business processes.
    To print a form, you need a program for data retrieval and a Smart Form that contains the entire from logic. As data retrieval and form logic are separated, you must only adapt the Smart Form if changes to the form logic are necessary. The application program passes the data via a function module interface to the Smart Form. When activating the Smart Form, the system automatically generates a function module. At runtime, the system processes this function module.
    You can insert static and dynamic tables. This includes line feeds in individual table cells, triggering events for table headings and subtotals, and sorting data before output.
    You can check individual nodes as well as the entire form and find any existing errors in the tree structure. The data flow analysis checks whether all fields (variables) have a defined value at the moment they are displayed.
    SAP Smart Forms allow you to include graphics, which you can display either as part of the form or as background graphics. You use background graphics to copy the layout of an existing (scanned) form or to lend forms a company-specific look. During printout, you can suppress the background graphic, if desired.
    SAP Smart Forms also support postage optimizing.
    Also read SAP Note No. 168368 - Smart Forms: New form tool in Release 4.6C
    What Transaction to start SAP Smart Forms?
    Execute transaction SMARTFORMS to start SAP Smart Forms.
    Key Benefits of SAP Smart Forms:
    SAP Smart Forms allows you to reduce considerably the implementation costs of mySAP.com solutions since forms can be adjusted in minimum time.
    You design a form using the graphical Form Painter and the graphical Table Painter. The form logic is represented by a hierarchy structure (tree structure) that consists of individual nodes, such as nodes for global settings, nodes for texts, nodes for output tables, or nodes for graphics.
    To make changes, use Drag & Drop, Copy & Paste, and select different attributes.
    These actions do not include writing of coding lines or using a Script language.
    Using your form description maintained in the Form Builder, Smart Forms generates a function module that encapsulates layout, content and form logic. So you do not need a group of function modules to print a form, but only one.
    For Web publishing, the system provides a generated XML output of the processed form.
    Smart Forms provides a data stream called XML for Smart Forms (XSF) to allow the use of 3rd party printing tools. XSF passes form content from R/3 to an external product without passing any layout information about the Smart Form.
    SmartForms System Fields
    Within a form you can use the field string SFSY with its system fields. During form processing the system replaces these fields with the corresponding values. The field values come from the SAP System or are results of the processing.
    System fields of Smart Forms
    &SFSY-DATE&
    Displays the date. You determine the display format in the user master record.
    &SFSY-TIME&
    Displays the time of day in the form HH:MM:SS.
    &SFSY-PAGE&
    Inserts the number of the current print page into the text. You determine the format of the page number (for example, Arabic, numeric) in the page node.
    &SFSY-FORMPAGES&
    Displays the total number of pages for the currently processed form. This allows you to include texts such as'Page x of y' into your output.
    &SFSY-JOBPAGES&
    Contains the total page number of all forms in the currently processed print request.
    &SFSY-WINDOWNAME&
    Contains the name of the current window (string in the Window field)
    &SFSY-PAGENAME&
    Contains the name of the current page (string in the Page field)
    &SFSY-PAGEBREAK&
    Is set to 'X' after a page break (either automatic [Page 7] or command-controlled [Page 46])
    &SFSY-MAINEND&
    Is set as soon as processing of the main window on the current page ends
    &SFSY-EXCEPTION&
    Contains the name of the raised exception. You must trigger your own exceptions, which you defined in the form interface, using the user_exception macro (syntax: user_exception <exception name >).
    Example Forms Available in Standard SAP R/3
    SF_EXAMPLE_01
    Simple example; invoice with table output of flight booking for one customer
    SF_EXAMPLE_02
    Similar to SF_EXAMPLE_01 but with subtotals
    SF_EXAMPLE_03
    Similar to SF_EXAMPLE_02, whereby several customers are selected in the application program; the form is called for each customer and all form outputs are included in an output request
    Advantages of SAP Smart Forms
    SAP Smart Forms have the following advantages:
    1. The adaption of forms is supported to a large extent by graphic tools for layout and logic, so that no programming knowledge is necessary (at least 90% of all adjustments). Therefore, power user forms can also make configurations for your business processes with data from an SAP system. Consultants are only required in special cases.
    2. Displaying table structures (dynamic framing of texts)
    3. Output of background graphics, for form design in particular the use of templates which were scanned.
    4. Colored output of texts
    5. User-friendly and integrated Form Painter for the graphical design of forms
    6. Graphical Table Painter for drawing tables
    7. Reusing Font and paragraph formats in forms (Smart Styles)
    8. Data interface in XML format (XML for Smart Forms, in short XSF)
    9. Form translation is supported by standard translation tools
    10. Flexible reuse of text modules
    11. HTML output of forms (Basis release 6.10)
    12. Interactive Web forms with input fields, pushbuttons, radio buttons, etc. (Basis-Release 6.10)

  • Please Help me with the error P6

    I recently installed the Primavera P6 but when I started
    using it for the first time I get the following error
    message :
    C:\Program files\Primavera\Project
    Management\Languages\comCaptions.en-us
    <br
    />Please help me with this error ;
    Thanks

    Hi,
    This sounds like an issue
    that might best be handled by support. You can find
    information on contacting support here:<br
    /><br
    />http://www.primavera.com/customer/support.asp<br
    />
    Thanks,
    Sean

  • Please help me with the iphone 4 trouble

    I'm using iphone4 and i saw a new update IOS7 and i press to update,the iphone is  updating than it turn off for 5 minutes later it turn on again but with the app's logo and it start to repeat again and again and I can not connect to itunes to fix,I do not know what to do ,hope you guys will help me with the iphone,i reallly need it right now

    Make sure you have the Latest Version of iTunes (v11) Installed on your computer
    iTunes free download from www.itunes.com/download
    Christine Hua wrote:
    the iphone is  updating than it turn off for 5 minutes later it turn on again but with the app's logo and it start to repeat again and again and I can not connect to itunes to fix,
    See Here  >  http://support.apple.com/kb/HT1808
    You may need to try this More than Once...
    Be sure to Follow ALL the Steps...
    But... if the Device has been Modified... this will Not necessarily work.
    Unauthorized modification of iOS  >  http://support.apple.com/kb/HT3743

  • Please help me with the code!!

    Dear All, I am going to simulate a TCP via UDP , and I have been asked for creating some specific methods , also additional helper methods are allowed but I can't avoid implementing any of the functions described below.
    I have bold the functions which are ambiguous to me.
    [click here to see the detail assignment explanation|http://www.net.t-labs.tu-berlin.de/teaching/ws0809/PD_labcourse/PDF/u5en.pdf|click here to see the detail assignment explanation]
    If you see anything wrong please post , thanks.
    &bull; rdt connect()
    This function sets all the parameters required for connecting to a server. Moreover, it opens a
    UDP socket.
    &bull; rdt listen()
    This function is the server-side counterpart of rdt connect(). It opens a UDP socket for
    incoming connections and sets all the required parameters.
    &bull; rdt send()
    This function takes an arbirary amount of data as input and writes it into a send buffer. It
    does not send anything to the network.
    &bull; rdt recv()
    This function returns the whole receive buffer. It does not really read data from the network,
    but only from the receive buffer.
    &bull; rdt select()
    This function does the whole work of moving data over the network. It behaves similar to the
    system call select(), i.e. it blocks until there is some data in the receive buffer. The received
    data can be subsequently read with rdt recv(). A flow diagram of the functionality of this
    function follows:
    &ndash; send all()
    This function sends all the data in the send buffer over the network to the receiver. If
    more than 500 bytes are present in the send buffer, more packets must be sent. The MSS
    (Maximum Segment Size) of an RDT packet is 534 bytes.
    *&ndash; select()*
    This is the well-known system call that waits until the receive buffer contains data.
    [ I don't know what to do with the buffer , and how to make it empty]
    &ndash; recv from()
    This is the well-known system all recv from() that reads data from the network.
    *&ndash; statemachine send()*
    This is a function that processes a newly received packet. In RDT 1.0 nothing is done here,
    becuase the sender does not expect any ACK packets from the receiver.
    &ndash; statemachine recv()
    This function processes incoming packets. In RDT 1.0 the header is removed and the
    payload copied to the receive buffer.
    &ndash; Payload
    rdt select() returns at this point if there&rsquo;s any data in the receive buffer. If not, it starts
    from the beginning.
    [ where the data should be returned?]
    This is my code:
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.DatagramPacket;
    import java.net.DatagramSocket;
    import java.net.InetAddress;
    import java.net.Socket;
    import java.net.SocketException;
    public class Ex5 {
        DatagramSocket socket , client_socket;
        DatagramPacket rcv_pkt;
        DatagramPacket send_pkt;
        byte[] sendData;
        byte[] receivedData;
        InetAddress ipaddr;
        int client_port;
        public void rdt_connect(String host , int client_port) throws IOException{
                this.client_port = client_port;
                client_socket = new DatagramSocket();
                ipaddr = InetAddress.getByName(host);
        public void rdt_listen(int port) throws SocketException{
            //byte[] buffer = new byte[1024];
            socket = new DatagramSocket(port);
            //DatagramPacket packet = new DatagramPacket(buffer, buffer.length );
        public DatagramPacket rdt_send() throws IOException{
            sendData = new byte[534];
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String inString = in.readLine();
            sendData = inString.getBytes();
            DatagramPacket send_packet = new DatagramPacket(sendData,sendData.length, ipaddr,client_port );
            return send_packet;
        public DatagramPacket rdt_recv(byte[] receivedData) throws IOException{
            //byte[] receivedData = new byte[1024];
            DatagramPacket received_packet = new DatagramPacket(receivedData, receivedData.length );
            //socket.receive(received_packet);
            return received_packet;
        public byte[] rdt_select() throws IOException{
            rcv_pkt = new DatagramPacket(receivedData,receivedData.length);
            while(!receivedData.equals(null)){
                return receivedData;
            send_all();
            return null;
        public void send_all() throws IOException{
            rcv_pkt = this.rdt_send();
            client_socket.send(rcv_pkt);
        public DatagramPacket select(){
            DatagramPacket local_rcv_pkt = null;
            while(receivedData != null){
                //local_rcv_pkt = rcv_pkt;
            return local_rcv_pkt;
        public void recv_from() throws IOException{
            rcv_pkt = select();
            socket.receive(rcv_pkt);
        public void statemachine_send(){
        public void statemachine_recv() throws IOException{
            String data = new String(rcv_pkt.getData());
            receivedData = data.getBytes();
            rcv_pkt = this.rdt_recv(receivedData);
    }

    public class Ex5 {
    DatagramSocket socket , client_socket;Surely you're not expected to implement the client and the server in the same class?
    while(!receivedData.equals(null)){
    return receivedData;
    }This is just nonsense.
    public DatagramPacket select(){See java.nio.channels.Selector.
    while(receivedData != null){
    //local_rcv_pkt = rcv_pkt;
    }More nonsense.
    I suggest if you don't understand the assignment you advise those who gave it to you, and/or review whatever supporting information you were supplied or have been taught.

  • Please Help me with the Work Item agent to agent forwarding error

    hi folks ,
    This is the error I am getting when I am trying to forward the work item from agent to agent.
    "Work item 000000017188: Method SAP_WAPI_FORWARD_WORKITEM not allowed for type F "
    Please Help in this regards. its Urgent.
    thanks in advance for your help
    Krishna Chaitanya

    The F type Workitem cannot be forwarded because it represents Workflow (Also Subworkflow) workitem Id.
    You have to find out with workitem which has status W(Dialog Work Item; Represents a Single-Step Task) from SWWWIHEAD table and status should be in process and the TOP_WI_ID should be the value that you are trying to forward.
    Thanks
    Arghadip

  • Please help me with the audio guys!!!

    I am trying to figure out how to run a signal from my nforce to my dolby digital reciever.  I am lost. Can I run an optical cable from the SPDIF to the reciever? I tried that and am getting no sound. Is the some hardware or software settings that need to be adjusted?? Please help me quick, I need this running by tonite! (Party)
    Thanks guys!

    maveric,
    You can only run an optical cable from nForce to your Home Theater System if you have an Abit NV7-133R.  It is the only nForce with Optical in/out.  You need to use an RCA Cable to go from your nForce to your Home Theater.
    Good Luck,
    Richard

Maybe you are looking for

  • Changes made in EMS are not reflected in EMC

    Hello all, I realise that this is 2013 discussion, but I could not find a 2010 section. My problem is simple: any change that I make inside the Exchange Shell is simply not reflected in the Console. It doesn't appear there. It can't be searched for.

  • There are no templates in my newly installed LR5, Swdish version for Windows 7. How to get them?

    Dear all, I have uesed LR since LR2, most recently in a purchased upgarde licence for LR5. Having now switched to a new "Windows 7 computer of high performance I had to subscribe to LR5 and PS in the new licencing model. I have thus downloade LR5, th

  • How i verified PG xml file uploaded.

    Hi, I have uploaded the PG xml file with import command. But when I go to the application, it still shows the same old file. I have asked DBA to bounce the Apache. The bounce does not work either. The import has worked for me in the past. But this we

  • Unable to open files from Finder

    I just bought my Macbook Pro yesterday.  This is my first Mac so bear with me.  I bought and installed Office for Mac.  The problem is that I cannot open files directly from Finder or the folder stack on my Dock.  If I trt to open a Word or Excel fil

  • Is it possible to use $[$U_UDFField.0.0] generally ?

    Dear Experts, Hi I'm newbie here and in SAP B1 as well. Here is the thing I want to know : Let's say I have a UDF (ex : U_SalesType) that is generally used in Sales Module (and also appear in every Sales Forms). Then I want to create a formatted sear