Socket reading -writing

hello friends i am new to this forum and looking forward for some help from you guys
suppose i open a socket and made a connection to the remote server
now i have one socket with me and another corrresponding socket with the server .i write a very long string containig
new lines out.println("vey long string");
and i close the socket or the function in which i am doing this job exits.
would the remote server able to read from its socket or not that is does the closing of socket on one side closes the whole connection.

if its a TCP socket if you close one side the connection is closed, so it will not be able to read from its socket.

Similar Messages

  • Socket reading & writing - minimize latency

    Hello,
    I'm having a big application which reads & writes on a regular socket, and I'm trying to reduce latency to the minimum.
    to understand & measure things a bit better, I've written a simple client/server couple app: client connects to server, sends messages of specified length, server echoes messages back to client, that reads them.
    I'm running both client & server on the same box so that I have no timestamps issues.
    for this test, rate of sending messages is 1 every 400ms, size of message is 512 Bytes.
    I get average Round Trip Time of 560 micro-seconds, but variations are impressive, with values between 28 micro-second and 1.5milliseconds.
    I'd like to try to lower this latency to the minimum possible, and would like to hear what are the FASTEST & most Jitter-free ways of doing so, and I'm ready to experiment.
    on the client I do initially:
    _out = new DataOutputStream(_socket.getOutputStream()); then write regularly with
    String msg = "whatever_512_characters_msg";
    _out.writeBytes(msg);server side:
    _in = new BufferedReader(new InputStreamReader(_socket.getInputStream()));
    _out = new PrintWriter(_socket.getOutputStream(), true);reading is done with _in.readLine()writing is done with _out.println(msg);even though things are working OK, I'm thinking there must be a faster way to do things...
    the goal is not to optimize throughput or bandwidth, but really latency for roughly 512 Bytes messages.
    any pointer would be appreciated...
    thanks

    - how do PrintWriter and BufferedOutputStream are supposed to compare ?Don't use a PrintWriter for network operations. It swallows exceptions that you need to know about. You can use a BufferedWriter, if the other end is going to use a Reader.
    - what would be the advantage of using a byteArray (have seen this in several places, but don't exactly know how to implement it)If the data is already in a byte[] array, just write it using OutputStream.write(), and read it at the other end using InputStream.read(byte[]). If you do this you need to loop when reading until you've assembled a complete message, whatever that means. In your case you may be better off sticking with readLine().
    - people mentionned NIO, how would that be useful in such case, knowing that I'm mostly going to handle single connections ?Don't bother. NIO is for thousands of connections, not one.

  • Performance issue: Tuning Reading/Writing to a Socket.

    I have use case where reading/writing to a Socket is spending over 25% of the time in NativeThread.current() (Called from within SocketChannelImpl) This is a native call and it occurred to me that there might be a Java JNI option which could improve this call in particular.
    This may be hprof giving incorrect information, but I don't know how to provide this. YourKit also shows this method as a big hit.
    I am not so worried about read0 and write0 as this is directly related to what the use case does.
    Can anyone suggest tuning options which might improve the performance of this call?
    Does anyone know a way to determine if the information regarding this call is accurate?
    TRACE 300250:
    sun.nio.ch.FileDispatcher.read0(FileDispatcher.java:Unknown line)
    sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:21)
    sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
    sun.nio.ch.IOUtil.read(IOUtil.java:200)
    sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
    my.AbstractSocket.readMessage(AbstractSocket.java:69)
    TRACE 300225:
    sun.nio.ch.FileDispatcher.write0(FileDispatcher.java:Unknown line)
    sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)
    sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:104)
    sun.nio.ch.IOUtil.write(IOUtil.java:60)
    sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:334)
    my.AbstractSocket.flush(AbstractSocket.java:47)
    my.AbstractSocket.sendMesg(AbstractSocket.java:37)
    TRACE 300259:
    sun.nio.ch.NativeThread.current(NativeThread.java:Unknown line)
    sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:331)
    my.AbstractSocket.flush(AbstractSocket.java:47)
    my.AbstractSocket.sendMesg(AbstractSocket.java:37)
    TRACE 300229:
    java.nio.Bits.copyToByteArray(Bits.java:Unknown line)
    java.nio.DirectByteBuffer.get(DirectByteBuffer.java:224)
    my.FieldFormat.readString(BoltFieldFormat.java:56)
    TRACE 300265:
    sun.nio.ch.NativeThread.current(NativeThread.java:Unknown line)
    sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:182)
    my.AbstractSocket.readMessage(AbstractSocket.java:69)
    CPU SAMPLES BEGIN (total = 11263) Tue Jul 14 16:29:15 2009
    rank self accum count trace method
    1 32.50% 32.50% 3660 300250 sun.nio.ch.FileDispatcher.read0
    2 30.68% 63.18% 3456 300225 sun.nio.ch.FileDispatcher.write0
    3 21.84% 85.02% 2460 300259 sun.nio.ch.NativeThread.current
    4 6.82% 91.84% 768 300229 java.nio.Bits.copyToByteArray
    5 5.69% 97.53% 641 300265 sun.nio.ch.NativeThread.current

    I would ignore it. All it does is:
    'Returns an opaque token representing the native thread underlying the invoking Java thread. On systems that do not require signalling, this method always returns -1.'I think the significant thing is that it is called while synchronized on 'stateLock', so if you have > 1 thread executing writes, the entire sync block will tend to be a bottleneck. I would aggregate the data for current() and read0(), or current() and write0(), and treat it all as I/O time.

  • Reading/Writing Objects from/to Sockets

    I have a list of objects on the Server side that I want to write to a Client. The code on the Server side looks like this
    Socket socket = serverSocket.accept( )
    ObjectOutputStream oos = new ObjectOutputStream( socket.getOutputStream());
    for ( int i = 0 ; i < list.size ( ) ; i++)
    oos.writeObject(list.get ( i ) ;
    }On the Client side it looks like this
    ServerSocket socket = new ServerSocket( 7000 )
    socket.accept ( )
    while( true )
    ObjectInputStream ois = new ObjectInputStream( socket.getInputStream( ) )
    Object obj = ois.readObject( )
    }My question is; how to "mark" on the server side that I written all the objects, so that I know on the client side when to end reading objects ?
    When dealing with bytes, to mark EOF one can do:
    socket.write(new byte[1])on the server side
    And on the client side
    while( socket.read != -1 )to know when to quit reading.

    You could just pass an EndObject that marks the end (e.g Byte or an own Object).
    But I don't think you need this. Most collections are Serializable so you can just pass your list to the stream.

  • Error reading/writing file "com.garageband.cs":`≤Ć». message

    Hey all! Don't know if anyone can help but I keep getting the message...
    " Error reading/writing file "com.garageband.cs":`≤Ć». " with a cancel button.
    If you click on it it does go away, but after a time playback starts skipping and stuff.
    Anyone help please?
    Thanks
    Righini

    first two things to try for “oddball” probs:
    http://www.bulletsandbones.com/GB/GBFAQ.html#oddballprobs
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • Error reading/writing file message when opening garageband and/or files

    I've been recently getting this message when I open garageband and files
    "Error reading/writing file\U201Ccom.apple.garageband.cs\U201D
    I've been in and repaired disk permissions and all that it says it is all fine, reinstall garageband and message still comes up, weird.
    not only is garageband being a nuisance, Mac OS X 10.6.2 is being a pain when shutting down telling me to restart the computer. This only happened since upgrading to 10.6. No one as yet knows this promble so I'm gonna have to ring apple and see what is going on here.
    and also my other problem is that mac doesn't seem as snappy anymore I noticed this before upgrading to 10.6 and made no difference when "cleanly" installing 10.6. I get a colour wheel popping up and i'm having to wait with simple tasks. iMac only 2 years old.

    i give up with this discussion forum no no one knows anything

  • Unable to read field value from main table - unexpected socket read error

    Hi Friends,
    While executing the below code, I am able to get the value of the field 'id' but i am unable to get the value for the 'materialnumber' field. i am getting the below exception
    +com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:158)
         at com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand.execute(RetrieveLimitedRecordsCommand.java:157)
         at updaterecords.main(updaterecords.java:126)
    Caused by: com.sap.mdm.internal.protocol.manual.ProtocolException: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:100)
         at com.sap.mdm.data.commands.AbstractRetrieveLimitedRecordsCommand.execute(AbstractRetrieveLimitedRecordsCommand.java:146)
         ... 2 more
    Caused by: java.io.IOException: Unexpected socket read.  Result is -1.
         at com.sap.mdm.internal.net.DataSocket.receiveData(DataSocket.java:59)
         at com.sap.mdm.internal.net.ConnectionImpl.readInt(ConnectionImpl.java:417)
         at com.sap.mdm.internal.net.ConnectionImpl.nextMessage(ConnectionImpl.java:501)
         at com.sap.mdm.internal.net.ConnectionImpl.receiveMessage(ConnectionImpl.java:472)
         at com.sap.mdm.internal.net.ConnectionImpl.send(ConnectionImpl.java:209)
         at com.sap.mdm.internal.net.ReservedConnection.send(ReservedConnection.java:105)
         at com.sap.mdm.internal.protocol.manual.AbstractProtocolCommand.execute(AbstractProtocolCommand.java:97)
         ... 3 more+
    import com.sap.mdm.commands.AuthenticateUserSessionCommand;
    import com.sap.mdm.commands.CommandException;
    import com.sap.mdm.commands.CreateUserSessionCommand;
    import com.sap.mdm.commands.DestroySessionCommand;
    import com.sap.mdm.commands.GetRepositoryRegionListCommand;
    import com.sap.mdm.data.Record;
    import com.sap.mdm.data.RegionProperties;
    import com.sap.mdm.data.ResultDefinition;
    import com.sap.mdm.data.commands.RetrieveLimitedRecordsCommand;
    import com.sap.mdm.ids.TableId;
    import com.sap.mdm.net.ConnectionException;
    import com.sap.mdm.net.ConnectionPool;
    import com.sap.mdm.net.ConnectionPoolFactory;
    import com.sap.mdm.schema.FieldProperties;
    import com.sap.mdm.schema.RepositorySchema;
    import com.sap.mdm.schema.commands.GetFieldListCommand;
    import com.sap.mdm.schema.commands.GetRepositorySchemaCommand;
    import com.sap.mdm.search.Search;
    import com.sap.mdm.server.DBMSType;
    import com.sap.mdm.server.RepositoryIdentifier;
    public class updaterecords {
         public static void main(String[] args) {
              try {               
                    String serverName = "159.112.6.26";
                    ConnectionPool connections = null;
                    try {
                         connections = ConnectionPoolFactory.getInstance(serverName);
                    } catch (ConnectionException e) {
                         e.printStackTrace();
                         return;
                   // specify the repository to use
                   // alternatively, a repository identifier can be obtain from the GetMountedRepositoryListCommand
                   String repositoryName = "DEMO";
                   String dbmsName = "MDMD";
                   RepositoryIdentifier reposId = new RepositoryIdentifier(repositoryName, dbmsName, DBMSType.ORACLE);
                   // get list of available regions for the repository
                   GetRepositoryRegionListCommand regionListCommand = new GetRepositoryRegionListCommand(connections);
                   regionListCommand.setRepositoryIdentifier(reposId);
                   try {
                        regionListCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   RegionProperties[] regions = regionListCommand.getRegions();
                   // create a user session
                   CreateUserSessionCommand sessionCommand = new CreateUserSessionCommand(connections);
                   sessionCommand.setRepositoryIdentifier(reposId);
                   sessionCommand.setDataRegion(regions[0]); // use the first region
                   try {
                        sessionCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   String sessionId = sessionCommand.getUserSession();
                   // authenticate the user session
                   String userName = "meter1";
                   String userPassword = "meter1";
                   AuthenticateUserSessionCommand authCommand = new AuthenticateUserSessionCommand(connections);
                   authCommand.setSession(sessionId);
                   authCommand.setUserName(userName);
                   authCommand.setUserPassword(userPassword);
                   try {
                        authCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   GetRepositorySchemaCommand cmd=new GetRepositorySchemaCommand(connections);
                   cmd.setSession(sessionId);
                   try{
                        cmd.execute();               
                   }catch(CommandException e){
                        System.out.println(e.getLocalizedMessage());
                   RepositorySchema repsch=cmd.getRepositorySchema();
                   // the main table, hard-coded
                   TableId mainTableId = new TableId(1);     
                   // specify the result definition (what to retrieve); in this example, nothing
                   ResultDefinition rd = new ResultDefinition(mainTableId);
                   // select all records
                   Search search = new com.sap.mdm.search.Search(mainTableId);
                   //get fields
                   GetFieldListCommand getFieldListCommand = new GetFieldListCommand(connections);
                   getFieldListCommand.setSession(sessionCommand.getUserSession());
                   getFieldListCommand.setTableId(mainTableId);
                   try {
                        getFieldListCommand.execute();
                   } catch (CommandException e) {
                        System.out.println(e);
                   FieldProperties[] lookupFields = getFieldListCommand.getFields();
                   // add fields to records to retrieve
                   rd.addSelectField(repsch.getFieldId("Products","Id"));
                   rd.addSelectField(repsch.getFieldId("Products","MaterialNumber"));                              
                   // retrieve the records
                   RetrieveLimitedRecordsCommand limitingCommand = new RetrieveLimitedRecordsCommand(connections);
                   limitingCommand.setSession(sessionId);
                   limitingCommand.setResultDefinition(rd);
                   limitingCommand.setSearch(search);
                   //limitingCommand.setPageSize(2000);
                   try {
                        limitingCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
                   System.out.println("Record count is " + limitingCommand.getRecords().getCount()+"\n");
                   Record[] records=limitingCommand.getRecords().getRecords();
    System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","Id"))+ " \n");
    System.out.println(records[0].getFieldValue(repsch.getFieldId("Products","MaterialNumber"))+ " \n");
                   // finally destroy the session
                   DestroySessionCommand destroySessionCommand = new DestroySessionCommand(connections);
                   destroySessionCommand.setSession(sessionId);
                   try {
                        destroySessionCommand.execute();
                   } catch (CommandException e) {
                        e.printStackTrace();
                        return;
              } catch (Exception e) {
                   System.out.println(e.getLocalizedMessage());
                   e.printStackTrace();
    Kindly let me know where i am going wrong. MaterialNumber field is a TEXT not a lookup table field.  Above fields are from the main table.
    Thanks,
    Raags

    Hi Friends,
    I got the solution. It was the error because of not having a the below statement.
    limitingCommand.setPageSize(1);
    As i havent used that statement, it was trying to get 1000 records, and i dont know exactly what makes this to get that error. Anyhow., As i want to use for updation, i cn live with one record.
    Thanks,
    Raags

  • Socket read error: connection reset by peer

    Hi.
    Has anybody experienced the error message �Socket read error: connection reset by peer�
    Please see below for detailed information.
    Appreciate your help
    Regards
    RT
    Enviroment specification
    Server: HP/UX 11.00 64-bit, Oracle RDBMS 8.1.6.0.0 64-bit
    2 firewalls between client and db.
    Client:
    Win 2000,
    SP3,
    Oracle Client 8.1.7.0.0 ,JDBC OCI (thin JDBC driver,class12.zip)
    JDK 1.3
    JRUN3.0
    The TCP protocol is being used in the communication
    Error messages
    Web Users receive:           Socket read error: connection reset by peer
    Trace files on the sever:      Read unexpected EOF ERROR on 18.
    Explanation: The error in the server sqlnet trace file, suggests that a client connection has terminated abnormally, i.e. client machine powered off, a cable removed or a network connection aborted without warning. No user has complained of such a problem and there is no client trace with an error.
    The problem
    The users of the java web application, experiencing an exception almost once or twice a day.
    The JRUN web-server reports broken connections to the db and client are receiving "connection reset by peer".
    At the moment when the errors occurs the users just have to wait a while(2-10 min) and then they can use the web application again.(no action is taken)
    This problem can not be reproduced. The problem happens only occasionally when the network is under heavy load and new DB connection is being created.
    The application
    The java web-application uses a customized connection pooling against the database. This pool is shared among all the users of the website. whenever a user process needs to fetch data from the database, a free connection from this pool is allocated. The application is testing if the connection is valid before making a transaction (select '1' from dual). When the error occurs a ORA-3113 end-of-file on communication channel is returned to the application.
    The path between the client and db involves at least two firewalls. The firewalls are opened for sql*net traffic. The network group can tell that enquiries from the app.server is not getting feedback from the db. They have not however, identified if the enquiries are reaching the db-srever, or if they are stopped earlier in the network.
    Around 1000 users, are using other applications which uses dedicated sqlnet connections against the db and they have not experienced any problems.
    Issues considered
    Connection pooling
    It is a customized connection pooling, developed by Lindorff developers.
    I have read through the source code for the connection pooling and it does the job as it should, and in case of bad connection, it tries to create a new connection.
    The log file shows that the call to the method DriverManager.getConnection() hangs until the server goes down, which is probably because of the fact that the method DriverManager.setLoginTimeout(), does not take effect and timeout value is Zero. ( According to oracle , Oracle JDBC does not support login timeouts and calling the static DriverManager.setLoginTimeout() method will have no effect).
    Firewall
    One thing to consider is when the firewall may decide to shut down the socket due to long inactivity of a connection. This will cause problems to JDBC Connection Pool because the pool is not aware of this disconnection at the TCP/IP level; until someone checks out the connection from the pool and tries to use it. The user will get a Socket read error: connection reset by peer.
    Jrun timeout paramter is less than the firewall�s timeout so the firewall will not close a connection before Jrun does.
    Number of processes the DB can handle
    Processes parameter is 1300, , they have not experienced the Oracle error msg �max # of processes reached�.
    Port redirection through a firewall:
    Since the firewall has a sql net proxy Port redirection through a firewall is not a problem. Problems with port redirection only appear at connect time, but in this situation the connections fail long after the connection is established.
    The network group
    The network people who investigaged the problem at Lindorff report that there are a significant amount of "dropped packages" between the database server and the jdbc client (web-application) 24 hrs. The reason for this is "unknown established TCP packet" which means that the firewall does not consider these packages to be part of an already established session. The network group believes this happen because one of the hosts send a RESET or FIN signal which the firewall have noticed but are not received by the other host.
    It seems like the firewall are dropping packages bacause of "Unknown
    established TCP packet" from both the JDBC client and the TNSLISTENER on the database server. The dropped packages are SQL*Net v2 traffic so clearly Oracle products are involved

    Presumably something is working.
    Thus the problem is not with your code. At least not the database part that you have control over.
    That error occurs when the other side closes the socket. Presumably you are catching lost connection exceptions and trying to restore it.

  • Keep getting message pop up "Error reading/writing file  "com.apple.logic.pro.cs": Logical end-of-file reached during read operation," and "The Preferences are not loaded completely. Save them to "com.apple.logic.pro.cs" anyway?" Using Logic pro 8. ???

    Logic froze while I was working on something so I forced quit.  Now every time I open LOGIC a message pops up that says:
    "Error reading/writing file
    “com.apple.logic.pro.cs”:
    Logical end-of-file reached during read operation."
    The only button option is cancel so I press it and another message appears that says:
    "The Preferences are not loaded completely.
    Do not save them, as you would overwrite the Preferences file with incomplete data."
    Then when i close logic a box appears saying:
    "The Preferences are not loaded completely.
    Save them to "com.apple.logic.pro.cs" anyway?"
    There are 3 button options to press; ok, cancel or dont save.
    I press "don’t save" cuz I don't want to ruin anything.
    I found a discussion located here: https://discussions.apple.com/message/9564253#9564253 that says if I delete the file "com.apple.logic.pro.cs" it will resolve the problem.  If I do this will I loose or mess anything up at all, automation, saved channel strips customizations, saved effects, synth, or ultrabeat customizations etc? Or especially will I loose any work I've done?  I have hundreds pieces of music files I've created.  I'm scared to mess anything up with all the hours and months of work I've done.  Is there anyway to fix this without loosing anything?  I'm using Logic Pro 8.
    Thank you

    You can safely delete this file - its the preference file for control surface settings - you haven't said whether you're actually using a control surface or not, if so, you will have to set it up again. A new file will be created when you fire Logic up again, but of course it will contain default settings. If you have a complicated control surface setup, remember to keep a backup copy somewhere in case any future problems arise.
    Other than that, you really have nothing to be scared about - hopefully your problem is as simple as that and there isn't an underlying problem (a corrupt hard drive, for example). You seem concerned about losing work, so I guess you want to think about backing that up on a regular basis too. If you're saving your projects to your system drive, do get an external one for this. And also check that you have plent of free space on your system drive - you need to keep about a quarter or third of it free for your OS and programs to run properly (some temporarily stored files can be quite large).

  • Stax reading /writing need help from xml guru plz

    hi, i have been told that stax reading /writing should involve no overhead and that is why i use it and i am now able to write my large data to file, but using my reader i seem to run out of memory, using netbeans profiler i ahve found that char[] seems to be the problem,
    by backtracing i ahve found that javax.xml.parser.SAXParser.parse calls the xerces packages which eventually leads to the char[ ], now my code for my reader is attatched here...
    package utilities;
    import Categorise.Collection;
    import Categorise.Comparison;
    import Categorise.TestCollection;
    import java.io.IOException;
    import javax.xml.parsers.*;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    import org.xml.sax.Attributes;
    import java.io.File;
    import java.util.ArrayList;
    import java.util.List;
    import measures.Protocol;
    * @author dthomas
    public class XMLParser extends DefaultHandler
        static Collection collection = new Collection();
        List<Short> cList;
        List<Comparison> comparisonList;
        File trainFileName;
        File testFileName;
        TestCollection tc;
        List<TestCollection> testCollectionList;
        List<File> testFileNameList = new ArrayList<File>();
        List<File> trainFileNameList = new ArrayList<File>();
        boolean allTrainsAdded = false;
        Protocol protocol;
        List<File> trainingDirList;
        File testingDir;
        int counter = 0;
        File[ ] trainingDirs;
        File[ ] trainingFileNames;
        File[ ] testFileNames;
        TestCollection[ ] testCollections;
        Comparison[ ] comparisons;
        Comparison c;
        short[ ] cCounts;
        String order;
        String value;
        File trainDir;
        /** Creates a new instance of XMLParser */
        public XMLParser() {
        public static Collection read( File aFile )
            long startTime = System.currentTimeMillis();
            System.out.println( "Reading XML..." );
            SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp;
            try {
                sp = spf.newSAXParser();
                sp.parse( aFile, new XMLParser() );
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (SAXException ex) {
                ex.printStackTrace();
            } catch (ParserConfigurationException ex) {
                ex.printStackTrace();
            long endTime = System.currentTimeMillis();
            long totalTime = ( endTime - startTime ) / 1000;
            System.out.println( "Done..."  + totalTime + " seconds" );
            return collection;
        public void startElement(String uri,String localName,String qName, Attributes attributes)
            if( qName.equals( "RE" ) )
                testCollectionList = new ArrayList<TestCollection>();
            else if( qName.equals( "p") )
                boolean isConcatenated = new Boolean( attributes.getValue( "c" ) );
                boolean isStatic = new Boolean( attributes.getValue( "s" ) );
                protocol = new Protocol( isConcatenated, isStatic );
            else if( qName.equals( "trdl" ) )
                trainingDirList = new ArrayList<File>();
            else if( qName.equals( "trd" ) )
                trainDir = new File( attributes.getValue( "fn" ) );
                trainingDirList.add( trainDir );
            else if( qName.equals( "td" ) )
                testingDir = new File( attributes.getValue( "fn" ) );
            else if( qName.equals( "TC" ) )
                counter++;
                System.out.println( counter );
                comparisonList = new ArrayList<Comparison>();
                testFileName = new File( attributes.getValue( "tfn" ) );
                testFileNameList.add( testFileName );
                tc = new TestCollection( );
                tc.setTestFileName( testFileName );
            else if ( qName.equals( "r" ) )
             order = attributes.getValue( "o" );
                value = attributes.getValue( "v" );
                cList.add( Short.parseShort( order ), new Short( value ) );
            else if( qName.equals( "c" ) )
                cList = new ArrayList<Short>();
                trainFileName = new File( attributes.getValue( "trfn" ) );
                if( !allTrainsAdded )
                    trainFileNameList.add( trainFileName );
        public void characters(char []ch,int start,int length)
            //String str=new String(ch,start,length);
            //System.out.print(str);
        public void endElement(String uri,String localName,String qName)
            if (qName.equals( "c") )
                allTrainsAdded = true;
                cCounts = new short[ cList.size() ];      
                for( int i = 0; i < cCounts.length; i++ )
                    cCounts[ i ] = cList.get( i );
                c = new Comparison( trainFileName, tc );
                c.setcCounts( cCounts );
                this.comparisonList.add( c );
            else if( qName.equals( "TC" ) )
                comparisons = new Comparison[ comparisonList.size() ];
                comparisonList.toArray( comparisons );           
                tc.setComparisons( comparisons );
                testCollectionList.add( tc );
            else if( qName.equals( "RE" ) )
                testCollections = new TestCollection[ testCollectionList.size() ];
                testCollectionList.toArray( testCollections );
                collection.setTestCollections( testCollections );
                testFileNames = new File[ testFileNameList.size() ];
                testFileNameList.toArray( testFileNames );
                collection.setTestingFiles( testFileNames );
                //String[ ] testCategories = new String[ testCategoryList.size() ];
                //testCategoryList.toArray( testCategories );
                //collection.setTestCategories( testCategories );
                trainingFileNames = new File[ trainFileNameList.size() ];
                trainFileNameList.toArray( trainingFileNames );
                collection.setTrainingFiles( trainingFileNames );
                //String[ ] trainingCategories = new String[ trainCategoryList.size() ];
                //trainCategoryList.toArray( trainingCategories );
                //collection.setTrainingCategories( trainingCategories );
                collection.setProtocol( protocol );
                trainingDirs = new File[ trainingDirList.size() ];
                trainingDirList.toArray( trainingDirs );           
                collection.setTrainingDirs( trainingDirs );
                collection.setTestingDir( testingDir );
         //else
             //System.out.println("End element:   {" + uri + "}" + localName);
    }i thought it may have been a recursive problme, hence having so many instance variables instead of local ones but that hasn't helped.
    all i need at the end of this is a Collection which holds an array of testCollections, which holds an array of cCounts and i was able to hold all of this in memory as all i am loading is what was in memory before it was written.
    can someone plz help
    ps when i use tail in unix to read the end of the xml file it doesnt work correctly as i cannot specify the number of lines to show, it shows all of the file as thought it is not split into lines or contains new line chars or anything, it is stored as one long stream, is this correct??
    here is a snippet of the xml file:
    <TC tfn="
    /homedir/dthomas/Desktop/4News2/output/split3/alt.atheism/53458"><c trfn="/homed
    ir/dthomas/Desktop/4News2/output/split0/alt.atheism/53586"><r o="0" v="0"></r><r
    o="1" v="724"></r><r o="2" v="640"></r><r o="3" v="413"></r><r o="4" v="245"></
    r><r o="5" v="148"></r><r o="6" v="82"></r><r o="7" v="52"></r><r o="8" v="40"><
    /r><r o="9" v="30"></r><r o="10" v="22"></r><r o="11" v="16"></r><r o="12" v="11
    "></r><r o="13" v="8"></r><r o="14" v="5"></r><r o="15" v="2"></r></c><c trfn="/
    homedir/dthomas/Desktop/4News2/output/split0/alt.atheism/53495"><r o="0" v="0"><
    /r><r o="1" v="720"></r><r o="2" v="589"></r><r o="3" v="349"></r><r o="
    please if anyone has any ideas from this code why a char[] would use 50% of the memory taken, and that the average age seems to show that the same one continues to grow..
    thanks in advance
    danny =)

    hi, i am still having lo luck with reading the xml data back into memory, as i have said before, the netbeans profiler is telling me it is a char[] that is using 50% of the memory but i cannot see how a char[] is created, my code doesn't so it must be the xml code...plz help

  • Reading/Writing .xlsx files using Webdynpro for Java

    Dear All
    I have a requirement to read/write excel files in .xlsx format. I am good in doing it with .xls format using jxl.jar. The jxl.jar doesn't support .xlsx format. Kindly help me in understanding how do I need to proceed on reading/writing .xlsx files using Webdynpro for Java.
    Thanks and Regards
    Ramamoorthy D

    i am using jdk 1.6.22 and IBM WebSphere
    when i use poi-3.6-20091214.jar and poi-ooxml-3.6-20091214.jar  to read .xlsx file. but i am getting following errors
    The project was not built since its classpath is incomplete. Cannot find the class
    file for java.lang.Iterable. Fix the classpath then try rebuilding this project.
    This compilation unit indirectly references the missing type java.lang.Iterable
    (typically some required class file is referencing a type outside the classpath)
    how can i resolve it
    here is the code that i have used
    public class HomeAction extends DispatchAction {
         public ActionForward addpage(
                             ActionMapping mapping,
                             ActionForm form,
                             HttpServletRequest request,
                             HttpServletResponse response)
                             throws Exception {     
                             String name = "C:/Documents and Settings/bharath/Desktop/Book1.xlsx";
               FileInputStream fis = null;
               try {
                   Object workbook = null;
                    fis = new FileInputStream(name);
                    XSSFWorkbook wb = new XSSFWorkbook(fis);
                    XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);
                    Iterator rows = sheet.rowIterator();
                    int number=sheet.getLastRowNum();
                    System.out.println(" number of rows"+ number);
                    while (rows.hasNext())
                        XSSFRow row = ((XSSFRow) rows.next());
                        Iterator cells = row.cellIterator();
                        while(cells.hasNext())
                    XSSFCell cell = (XSSFCell) cells.next();
                    String Value=cell.getStringCellValue();
                    System.out.println(Value);
               } catch (IOException e) {
                    e.printStackTrace();
               } finally {
                    if (fis != null) {
                         fis.close();
                return mapping.findForward("returnjsp");

  • " DVD RW Drive " is not reading / writing DVD. It can read only CD.

    HP Pavilion dv6-3140se Entertainment Notebook PC 
    {Personal Information Removed}
    Product Number:   XS065EA 
    " DVD RW Drive "  is not reading / writing DVD.  
    The same DVD can be read on my frnds laptop. 
    Corresponding drivers r up to date.. I even tried uninstall and then restart and then let my laptop install the required driver automatically. I've tried everything I could find on some forums.
    I was told to delete " Upper & Lower filters ". I didnt find Lower filter so I had to delete only "Upper Filter".
    Plz assist me..
    I will be waiting for ur kind reply.
    Thank u so much.

    The upper and lower filter thing only applies if the drive is not showing up at all in the Device Manager. If it appears as a drive and will perform any function at all, then it is likely a hardware issue. One way you can be sure is to try to boot from a bootable DVD such as a Windows 7 install Disk. If the computer will not boot from such a disk then it is apparent the hardware is defective, not the Windows software because the problem exists even before Windows loads.
    The drive has multiple lasers and it is possible for one to go out but not the others.  The drive is easily replaced. See below:
    This eBay seller ships worldwide. You would have to transplant your plastic drive face but that is very easy to do:
    http://www.ebay.com/itm/HP-Pavilion-DV6-3000-DVD-RW-DVD-RW-Multi-Burner-Drive-TS-L633-603677-001-B-/...

  • Socket read() call returning before timeout.

    I have a couple of applications which use the following basic socket reading approach:
    Socket socket = new Socket("192.168.0.1", 54321);
    socket.setSoTimeout (5000);
    InputStream stream = socket.getInputStream();
    byte[] data = new byte[232];
    boolean done = false;
    while (!done) {
        int res= stream.read(data);
        if (res < data.length) {
            System.err.println ("Error reading packet data - not enough data received: "+ res);
        // process and output the data
    try { stream.close(); } catch (Exception e) {}
    try { socket.close(); } catch (Exception e) {}The problem I am having is that sometimes read(byte[]) returns a before the full array's worth of data has been read, and before a timeout has occurred. I never get a SocketTimeoutException, but I do get my debugging output. I have recorded the network traffic with a packet sniffer (Wireshark), and what I am seeing is that in the instances where the read returns prematurely, it stops at the end of a TCP packet. The rest of the data is in another packet that arrives shortly afterwords (~1.5 ms or less).
    I know that with normal (file) input streams, read can return whenever it wants regardless of how many bytes were read, however I was under the impression that network streams are supposed to block until all the data arrives (or a timeout occurs, if set). Is this incorrect?

    djpeaco wrote:
    I know that with normal (file) input streams, read can return whenever it wants regardless of how many bytes were readThat's correct and that's exactly the reason you see the behavior you see.
    however I was under the impression that network streams are supposed to block until all the data arrives (or a timeout occurs, if set).Why? Why do you think that network streams behave differently in this regard?
    Why shouldn't it give you the data as soon as it's available, when every other stream works this way?
    Is this incorrect?Yes, you must assume that the streams of a socket follow the general InputStream/OutputStream contract and that includes possibly returning from read() before the full array is filled.

  • IO Error: Socket read timed out / IOP_iopinstance1_datasource" closed

    Hi ,
    Can somebody suggest what could be the probable cause of following errors showing up in IOP log file?
    ####<Aug 16, 2011 10:49:11 PM PDT> <Info> <Common> <sc-csttest> <IOPServer_iopinstance1> <weblogic.work.j2ee.J2EEWorkManager$WorkWithListener@357ac2f7> <<anonymous>> <> <0000J7MI9kZFk3vLsYw0yX1EIpFA00002K> <1313560151943> <BEA-000628> <Created "1" resources for pool "IOP_iopinstance1_datasource", out of which "1" are available and "0" are unavailable.>
    ####<Aug 16, 2011 10:49:12 PM PDT> <Info> <JDBC> <sc-csttest> <IOPServer_iopinstance1> <weblogic.work.j2ee.J2EEWorkManager$WorkWithListener@357ac2f7> <<anonymous>> <> <0000J7MI9kZFk3vLsYw0yX1EIpFA00002K> <1313560152146> <BEA-001128> <Connection for pool "IOP_iopinstance1_datasource" closed.>
    java.sql.SQLRecoverableException: IO Error: Socket read timed out
    Thanks
    Lokesh

    This particular error means your database is down and socket is timedout. Or the query takes so long that the reader timedout -- unlikely.
    Also, the general weblogic socket write errors, which you might see sometimes means that the client got disconnected before the server wrote results back. This is harmless

  • Socket Read Timeout error in weblogic logs happening every 30 min

    One of my customer is getting Socket Read Time out error, when creating connection pool.
    java.sql.SQLException: Socket read timed out
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:74)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:135)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:203)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:489)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:439)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:640)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:205)
         at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:554)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(ConnectionEnvFactory.java:327)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:227)
         at weblogic.common.resourcepool.ResourcePoolImpl.makeResources(ResourcePoolImpl.java:1193)
         at weblogic.common.resourcepool.ResourcePoolImpl$ResourcePoolMaintanenceTask.timerExpired(ResourcePoolImpl.java:2451)
         at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused By: oracle.net.ns.NetException: Socket read timed out
         at oracle.net.ns.Packet.receive(Packet.java:333)
         at oracle.net.ns.DataPacket.receive(DataPacket.java:94)
         at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:176)
         at oracle.net.ns.NetInputStream.read(NetInputStream.java:121)
         at oracle.net.ns.NetInputStream.read(NetInputStream.java:96)
         at oracle.net.ns.Packet.extractData(Packet.java:443)
         at oracle.net.ns.AcceptPacket.<init>(AcceptPacket.java:108)
         at oracle.net.ns.NSProtocol.setNetStreams(NSProtocol.java:697)
         at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
         at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1088)
         at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:305)
         at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:642)
         at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:205)
         at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:554)
         at weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(ConnectionEnvFactory.java:227)
         at weblogic.common.resourcepool.ResourcePoolImpl$ResourcePoolMaintanenceTask.timerExpired(ResourcePoolImpl.java:2451)
         at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Any suggestions?

    Could be a firewall rule terminating an idle connection?

Maybe you are looking for