How to read out a InputStream from a socket?

Hei,
I try to write a programm that should also be accessed via telnet. So I wrote a classe that has a ServerSocket, a Socket, an InputStream and an OutputStream.
I read out the InputStream via a byte arry, but the inputStream always starts with the first line I entered. How do I empty the Stream? Mark is not supported :(
So what can I do, to get only the last enty?
big thx,

use the other read option, see:[url http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html#read()]InputStream#read
This allows you to read from an offset.

Similar Messages

  • HOW TO  FIND OUT TABLE DESCRIPTION FROM JDBC?

    HOW WILL FIND OUT TABLE DESCRIPTION FROM JDBC?

    Have a look at ResultSetMetaData
    getColumnCount()
    getColumnName(int)
    getColumnTypeName(int)
    getColumnDisplaySize(int)
    ***Annie***

  • How to read line number text from PDF using plugin?

    Hi, I would like to know how to read line number text from PDF using plugin?
    Thanks in advance.

    Ok, some background reading of the PDF Reference will help you understand why this is so difficult. PDF files are not organised into lines. It is best to think of each word or character on the page as being a graphic with its own position. The human eye sees lines where a series of graphics (words) are roughly in the same horizontal region.
    In the general case it is difficult or even impossible to answer this. You may have columns with different spacing (but the PDF stores no information on what is a column). You may have subscripts and superscripts. You may have text in graphics coinciding with other text. Commonly, there may be titles, headings or page numbers which are just ordinary text and might count as lines.
    That said, what you need to do is extract the text on the page and its positions. The WordFinder APIs are the way to do that. Now, sort all the words out, using the Y coordinates and size to try and guess what makes a "line". Now you are in a position to find the text (divided into words, not strings) and report the "line number" you have estimated.

  • How to find out company code from a plant ?

    Hello friends,
    I have to modify a program that uses FM "BAPI_COMPANYCODE_GET_PERIOD".   For that, we have to export company code ID.  Currently it is hard coded with one company code.  Now we want to make this program usable by all company codes.  So instead of hard coding, I would like to dynamically find out company code based on the plant.   So I want to know - how to find out company code from a plant ?  Is there any table that has plant to company-code assignment data, or any other FM/BAPI to get this info ?
    Thanks,
    - Chetan

    hi
    u can find this from table T001K
    or just goto EC01
    here click on STRUCTURE>NAVIGATION
    double click on co code u will get the list
    u can slo try this in EC02
    regards
    kunal

  • Code for how to read an integer array from the command prompt...

    hello,
    Could anyone give me the code for how to read an integer array from the command prompt...its very urgent!..

    If you are using a recent version of Java (5 or later) you can use Scanner:
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    That page has some example code on it, too.

  • How to Read a CAB File from JAVA?

    Hi,
    Anyone knows how to read a CAB File from java. I need to read a property file of txt file that is packaged in CAB file & then based on that, I have to do processing. Is there anyway to do it.
    I had tried using java.util.zip.ZipFile Class, but it does work for JAR, but not for CAB.
    siva.

    Perhaps there's something in the Cabinet SDK that will help:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp

  • How to print out multilingual reports from the main report using Xliff temp

    Hi all,
    How to print out multilingual reports from the main report using Xliff temp?
    When I want main report call subtemplate and finish xliff tranlation
    <?for-each@section:INVOICE?><?end for-each?>
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
    <?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
    Prints out fine with Finnish translation
    But if I want in main program to check what language is used e.g.
    if trx_number = 142 call Finnish translation and if trx_number =144,
    call English translation.
    <?for-each@section:INVOICE?><?end for-each?>
    <?if:TRX_NUMBER=’142’?>
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
    <?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
    <?end if?>
    <?if: TRX_NUMBER=’144’?>
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
    <?start:body?><?call:Header?><?call:Line?><?call:Weights?><?call:Banks?><?end body?><?call:Footer?>
    <?end if?>
    Prints out always in English and never the Finnish translation.
    Program goes fine to if branch but does not print out Finnish
    Does anybody know what could be wrong?
    BR
    Kari

    Thanks Amit,
    I have two layout, main-layout and sub-layout
    Main layout call subtemplate
    I have registered layout and xliff-file
    Main template
    Localized Templates
    File Name           Language Territory
    XXNS_INVOICE_MAIN.rtf      English
    SUB template
    Localized Templates
    File Name           Language Territory
    XXNS_INVOICE_SUB.rtf      English
    Translatable Template
    File Name           Language      Territory
    XXNS_INVOICE_SUB.rtf      English      United States
    Available Translations
    Language Territory Progress
    English Finland Complete
    If main report call subtemplate and finish xliff tranlation
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
    Prints out fine with Finnish translation
    But if I want in main program to check what language is used e.g.
    if....
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.FI/?>
    .....end if;
    if....
    <?import:xdo://XXIH.XXNR_XXINVPRINT_SUB.en.US/?>
    .....end if;
    Prints out always in English and never the Finnish translation.
    Program goes fine to if branch but does not print out Finnish
    Do you it's set up problem or program problem
    BR
    Kari

  • CSM3.1 did not read out VPN-Configuration from ASA

    Hello,
    i have installed an CSM 3.1 (build 482)on a Windows 2003 Server.
    When I read out the Configuration from my ASA5520 (7.2.(19)it still works fine, but the Configuration from my VPN-Tunnels to my Locations will not be read out.
    Any Idea for my Problem?
    Best Regards
    Hartmut

    Hi Hartmut
    Pls send a email to [email protected] with more details about your problem and CSM development team should be able to help you with this issue.
    Thanks,
    Brahma

  • How to read out message cycle time from Vector CANdb file?

    Hello LabVIEW friends,
    I tried to open a Vector CAN Database (*.dbc) using the NI-CAN 2.3.2 Channel API and read out the cycle time of a message.
    The CAN get property.vi should provide the sample rate which is described as followed:
    Input parameter of the CAN Init Start function.
    The sample rate specifies
    whether to transfer data in a periodic or event-driven manner.
    For periodic
    behavior, the rate specifies the number of read/write samples to perform per
    second.
    But for all messages in my database I get the value 0.
    When I connect a sample rate to the CAN Initialize.vi I will get it's value.
    Could anybody help?
    Thank You.
    Greets,
    Marcus

    Hi,
    unfortunately there is no way to use the cycle time property from your DBC file, because the NI driver is not able to read this information.
    This is because the cycletime is stored in different places for different users and only Vector itself can read this information back.
    In your case, you have to figure out this information by yourself and you can use the sample rate input of the init or initstart function to configure the cycle time in Hz.
    If you need different cycle times for different messages, see the attached example.
    DirkW
    Attachments:
    CAN_Multi-Chans_Diff-Period.vi ‏26 KB

  • How to find out histotry command from other session

    Hi gurus,
    I use RHEL 5.4
    Some user log onto server with root and make change at some files. How can I find out history command from other session with the same user.
    history command is just give me history commands of my own session.
    Thanks
    Ch

    The file which holds the commandline history is .bash_history in the home directory of the user.
    So in the case of root, /root/.bash_history
    Please mind that if you log in as root, or become root your session will add to that file as well.
    Another issue with the history file is that when multiple sessions are logged in, every session writes in its own version of the same file. So the last one "wins", which means that version is the one which is truly stored.
    If files are changed, a find command with the 'mtime' parameter should be helpful.

  • How to read a certain range from binary file

    Dear all LabView experts!
    I've attempted to acquire data as fast as I can from TDS 2024 via GPIB interface. The data will be saved into one binary file and be used for later analysis.
    The program that is included here will perform continuous acquiring and save all the points into 1 file.
    I used WHILE loop to do this job and each loop will take 2500 points from the scope.
    After that, I would like to read the file such that every 2500 points will be read out and analyzed.
    can you please show me how to do this?
    I've acknowleged that 2 inputs: pos. mod and pos.offset should be able to provide random access to the binary at any point. However, I cannot have this done
    THank you very much
    Attachments:
    streaming-testing1.vi ‏66 KB

    Hi CSUEB,
          Thanks for your patience - and for the sample data.
    Here's a Reader VI that will work (as long as the byte-stream type length is 20004 elements.)
    Cheers!
    "Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
    Attachments:
    streaming-testing_Reader_6i.vi ‏71 KB

  • Having issues finding out how many bytes are sent/recieved from a socket.

    Hello everyone.
    I've searched the forums and also google and it seems I can't find a way to figure out how many bytes are sent from a socket and then how many bytes are read in from a socket.
    My server program accepts a string (an event) and I parse that string up, gathering the relevant information and I need to send it to another server for more processing.
    Inside my server program after receiving the data ( a string) I then open another port and send it off to the other server. But I would like to know how many bytes I send from my server to the other server via the client socket.
    So at the end of the connection I can compare the lengths to make sure, I sent as many bytes as the server on the other end received.
    Here's my run() function in my server program (my server is multi threaded, so on each new client connection it spawns a new thread and does the following):
    NOTE: this line is where it sends the string to the other server:
    //sending the string version of the message object to the
                        //output server
                        out.println(msg.toString());
    //SERVER
    public class MultiThreadServer implements Runnable {
         Socket csocket;
         MultiThreadServer(Socket csocket) {
              this.csocket = csocket;
         public void run() {
              //setting up sockets
              Socket outputServ = null;
              //create a message database to store events
              MessageDB testDB = new MessageDB();
              try {
                   //setting up channel to recieve events from the omnibus server
                   BufferedReader in = new BufferedReader(new InputStreamReader(
                             csocket.getInputStream()));
                   //This socket will be used to send events to the z/OS reciever
                   //we will need a new socket each time because this is a multi-threaded
                   //server thus, the  z/OS reciever (outputServ) will need to be
                   //multi threaded to handle all the output.
                   outputServ = new Socket("localhost", 1234);
                   //Setting up channel to send data to outputserv
                   PrintWriter out = new PrintWriter(new OutputStreamWriter(outputServ
                             .getOutputStream()));
                   String input;
                   //accepting events from omnibus server and storing them
                   //in a string for later processing.
                   while ((input = in.readLine()) != null) {
                        //accepting and printing out events from omnibus server
                        //also printing out connected client information
                        System.out.println("Event from: "
                                  + csocket.getInetAddress().getHostName() + "-> "
                                  + input + "\n");
                        System.out.println("Waiting for data...");
                        //---------putting string into a message object-------------///
                        // creating a scanner to parse
                        Scanner scanner = new Scanner(input);
                        Scanner scannerPop = new Scanner(input);
                        //Creating a new message to hold information
                        Message msg = new Message();                    
                        //place Scanner object here:
                        MessageParser.printTokens(scanner);
                        MessageParser.populateMessage(scannerPop, msg, input);
                        //calculating the length of the message once its populated with data
                        int length = msg.toString().length();
                        msg.SizeOfPacket = length;
                        //Printing test message
                        System.out.println("-------PRINTING MESSAGE BEFORE INSERT IN DB------\n");
                        System.out.println(msg.toString());
                        System.out.println("----------END PRINT----------\n");
                        //adding message to database
                        testDB.add(msg);
                        System.out.println("-------Accessing data from Map----\n");
                        testDB.print();
                        //---------------End of putting string into a message object----//
                        //sending the string version of the message object to the
                        //output server
                        out.println(msg.toString());
                        System.out.println("Waiting for data...");
                        out.flush();
                   //cleaning up
                   System.out.println("Connection closed by client.");
                   in.close();
                   out.close();
                   outputServ.close();
                   csocket.close();
              catch (SocketException e) {
                   System.err.println("Socket error: " + e);
              catch (UnknownHostException e) {
                   System.out.println("Unknown host: " + e);
              } catch (IOException e) {
                   System.out.println("IOException: " + e);
    }Heres the other server that is accepting the string:
    public class MultiThreadServer implements Runnable {
         Socket csocket;
         MultiThreadServer(Socket csocket) {
              this.csocket = csocket;
         public void run() {
              try {
                   //setting up channel to recieve events from the parser server
                   BufferedReader in = new BufferedReader(new InputStreamReader(
                             csocket.getInputStream()));
                   String input;
                   while ((input = in.readLine()) != null) {
                        //accepting and printing out events from omnibus server
                        //also printing out connected client information
                        System.out.println("Event from: "
                                  + csocket.getInetAddress().getHostName() + "-> "
                                  + input + "\n");
    System.out.println("Lenght of the string was: " + input.length());
                        System.out.println("Waiting for data...");
                   //cleaning up
                   System.out.println("Connection closed by client.");
                   in.close();
                   csocket.close();
              } catch (IOException e) {
                   System.out.println(e);
                   e.printStackTrace();
    }Here's an example of the program works right now:
    Someone sends me a string such as this:
    Enter port to run server on:
    5656
    Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=5656]
    Waiting for client connection...
    Socket[addr=/127.0.0.1,port=4919,localport=5656] connected.
    hostname: localhost
    Ip address: 127.0.0.1:5656
    Waiting for data...
    Event from: localhost-> UPDATE: "@busch2.raleigh.ibm.com->NmosPingFail1",424,"9.27.132.139","","Omnibus","Precision Monitor Probe","Precision Monitor","@busch2.raleigh.ibm.com->NmosPingFail",5,"Ping fail for 9.27.132.139: ICMP reply timed out",07/05/07 12:29:12,07/03/07 18:02:31,07/05/07 12:29:09,07/05/07 12:29:09,0,1,194,8000,0,"",65534,0,0,0,"NmosPingFail",0,0,0,"","",0,0,"",0,"0",120,1,"9.27.132.139","","","","dyn9027132107.raleigh.ibm.com","","","",0,0,"","","NCOMS",424,""
    Now my program makes it all nice and filters out the junk and resends the new string to the other server running here:
    Enter port to run server on:
    1234
    Listening on : ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=1234]
    Waiting for client connection...
    Socket[addr=/127.0.0.1,port=4920,localport=1234] connected.
    Parser client connected.
    hostname: localhost
    Ip address: 127.0.0.1:1234
    Event from: localhost-> PacketType: UPDATE , SizeOfPacket: 577 , PacketID: 1, Identifer: UPDATE: "@busch2.raleigh.ibm.com->NmosPingFail1" , Serial: 424 , Node: "9.27.132.139" , NodeAlias: "" , Manager: "Omnibus" , Agent: "Precision Monitor Probe" , AlertGroup: "Precision Monitor" , AlertKey: "@busch2.raleigh.ibm.com->NmosPingFail" , Severity: 5 , Summary: "Ping fail for 9.27.132.139: ICMP reply timed out",StateChange: 07/05/07 12:29:12 , FirstOccurance: 07/03/07 18:02:31 , LastOccurance: 07/05/07 12:29:09 , InternalLast: 07/05/07 12:29:09 , EventId: "NmosPingFail" , LocalNodeAlias: "9.27.132.139"
    Lenght of the string was: 579
    The length of the final string I sent is 577 by using the string.length() function, but when I re-read the length after the send 2 more bytes got added, and now the length is 579.
    I tested it for several cases and in all cases its adding 2 extra bytes.
    Anyways, I think this is a bad solution to my problem but is the only one I could think of.
    Any help would be great!

    (a) You are counting characters, not bytes, and you aren't counting the line terminators that are appended by println() and removed by readLine().
    (b) You don't need to do any of this. TCP doesn't lose data. If the receiver manages get as far as reading the line terminator when reading a line, the line will be complete. Otherwise it will get an exception.
    (c) You are assuming that the original input and the result of message.toString() after constructing a Message from 'input' are the same but there is no evidence to this effect in the code you've posted. Clearly this assumption is what is at fault.
    (d) If you really want to count bytes, write yourself a FilterInputStream and a FilterOutputStream and wrap them around the socket streams before decorating them with the readers you are using. Have these classes count the bytes going past.
    (e) Don't use PrintWriter or PrintStream on socket streams unless you like exceptions being ignored. Judging by your desire to count characters, you shouldn't like this at all. Use BufferedWriter's methods to write strings and line terminators.

  • How to read time capsule files from iphone

    any one knows how to do this?
    i have used in the past an application call Soonr to access the mac but haven't tried if it works with time capsule.
    thanks for any thoughts/suggestions...

    Hi Harish,
    U can read all the files from a App's dir with this FM.
      CONCATENATE  '' '.'
             INTO LV_FILE1.
    *FM lists out the files present in App Server directory matching with given pattern.
      CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
        EXPORTING
          DIR_NAME                     = DIR_NAME
          FILE_MASK                    = LV_FILE1
       IMPORTING
    DIR_NAME                     =
         FILE_COUNTER                 =  FLE_CNT
    ERROR_COUNTER                =
        TABLES
          DIR_LIST                     = IT_DIRTAB
       EXCEPTIONS
         INVALID_EPS_SUBDIR           = 1
         SAPGPARAM_FAILED             = 2
         BUILD_DIRECTORY_FAILED       = 3
         NO_AUTHORIZATION             = 4
         READ_DIRECTORY_FAILED        = 5
         TOO_MANY_READ_ERRORS         = 6
         EMPTY_DIRECTORY_LIST         = 7
         OTHERS                       = 8
    Regards,
    KC

  • How to print out the data from the file ?

    hi all,
    i have upload my file to here :
    [http://www.freefilehosting.net/ft-v052010-05-09 ]
    anyone can help me to print out the data from the file ?
    the content of the file should be like this :
    185.56.83.89 156.110.16.1 17 53037 53 72 1
    and for the seven column is
    srcIP dstIP prot srcPort dstPort octets packets

    hi all,
    i have try to do this
    public static void Readbinary() throws Exception
              String file = "D:\\05-09.190501+0800";
              DataInputStream dis = new DataInputStream(new FileInputStream(file));
              //but then how to read the content ??????can you give me more hint ?????
    i have find the netflow v5 structure by C
    struct NFHeaderV5{
    uint16_t version; // flow-export version number
    uint16_t count; // number of flow entries
    uint32_t sysUptime;
    uint32_t unix_secs;
    uint32_t unix_nsecs;
    uint32_t flow_sequence; // sequence number
    uint8_t engine_type; // no VIP = 0, VIP2 = 1
    uint8_t engine_id; // VIP2 slot number
    uint16_t reserved; // reserved1,2
    struct NFV5{ 
    ipv4addr_t srcaddr; // source IP address
    ipv4addr_t dstaddr; // destination IP address
    ipv4addr_t nexthop; // next hop router's IP address
    uint16_t input; // input interface index
    uint16_t output; // output interface index
    uint32_t pkts; // packets sent in duration
    uint32_t bytes; // octets sent in duration
    uint32_t first; // SysUptime at start of flow
    uint32_t last; // and of last packet of flow
    uint16_t srcport; // TCP/UDP source port number or equivalent
    uint16_t dstport; // TCP/UDP destination port number or equivalent
    uint8_t pad;
    uint8_t tcp_flags; // bitwise OR of all TCP flags in flow; 0x10
    // for non-TCP flows
    uint8_t prot; // IP protocol, e.g., 6=TCP, 17=UDP, ...
    uint8_t tos; // IP Type-of-Service
    uint16_t src_as; // originating AS of source address
    uint16_t dst_as; // originating AS of destination address
    uint8_t src_mask; // source address prefix mask bits
    uint8_t dst_mask; // destination address prefix mask bits
    uint16_t reserved;
    but how to translate the structure to java,then get the data from the file ?
    Edited by: 903893 on Dec 21, 2011 10:52 PM

  • How to read out a RPM signal in labview using UMI 7764 and PCI 7330

    Hi
    I have a problem getting a encoder signal into a labview program. The encoder is connected to a UMI 7764 motion device. This device is connected to a PC trough a PCI 7330. I heard rumors that I can't have more than two axis on a PCI 7330. But can I have more than 2 encoders on it?
    The big problem is that I am new to the motion system and I don't know where to begin.
    I'm going to finish a uncompleted system, but when I look at the VI, I get nervous. So you are my last hope.
    I have taken screen captures of the VI and uploaded it.
    My task is to implement a new encoder signal to the already-made VI.
    Question is:
    How do I add and read out a RPM signal from a new encoder?
    VI download:
    http://www.mediafire.com/?k1ckbozeppffv1z
    Best regards
    Henrik Myhre

    From your post it seems like you wants to read back the RPM value of a particular move based on your encoder. There actually is a specific VI that you can use that does exactly this. The Read Velocity in RPM.VI should output the RPM of the current move that you are doing.
    In the code that you posted, it looks like you are performing a two axis move. Therefore you will need two instances of this VI, one for each axis. You should utilize these VIs within the while loop and after the move has been started that way the RPM values are continuously updated.
    It also seems like you have inherited some code that looks very complicated. We would highly recommend that the you begins experimenting with basic motion to get familiar with it.

Maybe you are looking for

  • FBL5N Report

    Hi Gurus, When I run the FBL5N report, I was not able to find the Assignment field information for Manual invoices. Normally the Assignment field should be displayed with the same document number of the particular invoice. Can anyone help me where th

  • Error Message "This Item has not been purchased"

    I just bought a brand new computer with Windows 7 and I just downloaded Itunes.  I couldn't remember my itunes password so I changed my password.  After changing my password, I changed my Email address since I was using an old one I don't have access

  • Add-on de Crystal Reports para b1 2005A

    Saludos,  necesitaría instalar el addon de crystal reports para sap b1 2005A, pero no encuentro el addon en  "Software Distribution Center". Quería saber como podía obtenerlo,  he visto algunos mensajes  sobre el tema pero referentes a la versión de

  • Connection to Windows 2008 Server via SMB hangs after standby

    After boot or reboot, I can easily "connect to server" in finder to the Windows Server 2008 machine via smb://hostname. The network and shares work good without connection drops. However, when my Macbook resumes from standby or hibernation, the mount

  • Sounblaster live value 5.1 digital freezes sys

    Hey, I am having trouble with my sounblaster li've value 5. digital (model # ct4780), everytime that I try to install it, my system will boot ok, windows will recognize the hardware and then everything will freeze completely. I am sure that it is not