Java 8 StreamCorruptedException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StreamCorruptedException class.

This code example shows how to use the following methods:
        int dataLen = readInt();
        if (dataLen <= 0) {
            throw new StreamCorruptedException("invalid data length: " + dataLen);
        } 
        if (dataLen > maxObjectSize) {
            throw new StreamCorruptedException(
                    "data length too big: " + dataLen + " (max: " + maxObjectSize + ')');
        } 
 
        return new CompactObjectInputStream(in, classResolver).readObject();
    } 
 
    @Override 
    public int available() throws IOException {
        return in.available();
    } 
 
    @Override 
    public void close() throws IOException {
        in.close();
6
CodeRank
This code example shows how to use the following methods:printStackTrace
                Object o = oi.readObject();
                if (o != null)
                    s = (Sample) o;
            } catch (StreamCorruptedException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block 
                e.printStackTrace();
            } 
        } 
 
        return s;
    } 
 
    public Sample getLastSample(Context c) {
        try { 
5
CodeRank
This code example shows how to use the following methods:accept, close, getLocalPort
        if (args.length > 0 && args[0].equals("-exit")) {
            return; 
        } 
 
        // bind to a random port 
        ServerSocket ss = new ServerSocket(0);
        int port = ss.getLocalPort();
 
        // signal test that we are started - do not remove this line!! 
        System.out.println(port);
        System.out.flush();
 
        // wait for manager to connect 
        Socket s = ss.accept();
        s.close();
        ss.close();
    } 
} 
7
CodeRank
This code example shows how to use the following methods:accept, close, getLocalPort
import java.io.FileOutputStream; 
 
public class ProcessAttachDebuggee { 
    public static void main(String args[]) throws Exception {
        // bind to a random port 
        ServerSocket ss = new ServerSocket(0);
        int port = ss.getLocalPort();
 
        // Write the port number to the given file 
        File f = new File(args[0]);
        FileOutputStream fos = new FileOutputStream(f);
        fos.write( Integer.toString(port).getBytes("UTF-8") );
        fos.close();
 
        System.out.println("Debuggee bound to port: " + port);
        System.out.flush();
 
        // wait for test harness to connect 
        Socket s = ss.accept();
        s.close();

7
CodeRank
This code example shows how to use the following methods:accept, bind, close, getLocalPort, getLocalSocketAddress
                Integer.MAX_VALUE);
    } 
 
    void performancePreferenceTest(int connectionTime, int latency,
            int bandwidth) throws Exception {
        ServerSocket theSocket = new ServerSocket();
        theSocket.setPerformancePreferences(connectionTime, latency, bandwidth);
 
        InetSocketAddress theAddress = new InetSocketAddress(InetAddress
                .getLocalHost(), 0);
        theSocket.bind(theAddress);
        int portNumber = theSocket.getLocalPort();
        assertTrue( 
                "Returned incorrect InetSocketAddress(2):" 
                        + theSocket.getLocalSocketAddress().toString()
                        + "Expected: " 
                        + (new InetSocketAddress(InetAddress.getLocalHost(),
                                portNumber)).toString(), theSocket
                        .getLocalSocketAddress().equals(
                                new InetSocketAddress(InetAddress

7
CodeRank
This code example shows how to use the following methods:accept, close
        System.out.println("INFO: " + myAppName + " is waiting on port: " +
            myPort);
        System.out.flush();
 
        // wait for test harness to connect 
        Socket s = mySS.accept();
        s.close();
        mySS.close();
 
        System.out.println("INFO: " + myAppName + " is shutting down.");
        System.out.flush();
    } 
 
    // execute the application start protocol 
    final public void doMyAppStart(String[] args) throws Exception {
        if (args.length < 1) {
            throw new RuntimeException("Usage: " + myAppName +
                " port-file [arg(s)]"); 
        } 
 
7
CodeRank
This code example shows how to use the following methods:accept, close, getLocalPort
    public static void main(String[] args) throws Exception {
        SetReceiveBufferSize s = new SetReceiveBufferSize();
    } 
 
    public SetReceiveBufferSize() throws Exception { 
        ServerSocket ss = new ServerSocket(0);
        Socket s = new Socket("localhost", ss.getLocalPort());
        Socket accepted = ss.accept();
        try { 
            s.setReceiveBufferSize(0);
        } catch (IllegalArgumentException e) {
            return; 
        } catch (Exception ex) {
        } finally { 
            ss.close();
            s.close();
            accepted.close();
        } 
        throw new RuntimeException("IllegalArgumentException not thrown!");
    } 
7
CodeRank
This code example shows how to use the following methods:accept, close, getLocalPort
 
public class OldUnixSocketTest extends TestCase {
 
    public void test_getInputStream() throws IOException { 
        // Simple read/write test over the IO streams 
        final ServerSocket pingServer = new ServerSocket(0);
        Socket pingClient = new Socket();
 
        try { 
            pingClient.connect(new InetSocketAddress(
                    InetAddress.getLocalHost(), pingServer.getLocalPort()));
 
            Socket worker = pingServer.accept();
            pingServer.close();
 
            // Write some data to the server to provoke it 
            OutputStream clientOut = pingClient.getOutputStream();
            clientOut.write(new byte[256]);
            InputStream in = worker.getInputStream();
            in.read();

7
CodeRank
This code example shows how to use the following methods:accept, close, getInetAddress, getLocalPort, getLocalSocketAddress
         * Es kann keine Verbindung mit dem Client via Internet hergestellt werden 
         */ 
        setup = false;
        int port = 4444;
                 
        ServerSocket serverSocket = new ServerSocket(port);
         
        System.out.println(serverSocket.getLocalPort());
        System.out.println(serverSocket.getLocalSocketAddress());
         
        System.out.println(serverSocket.getInetAddress().getHostName());
         
         
        System.out.println("\nServer gestartet");
        setup = true;
        client = warteAufAnmeldung(serverSocket);
        String nachricht = null;
        if(connected)
        { 
            nachricht = leseNachricht();

6
CodeRank
This code example shows how to use the following methods:
				return super.readClassDescriptor(); 
			case 1: 
				Class<?> clazz = loadClass(readUTF());
				return ObjectStreamClass.lookup(clazz);
			default: 
				throw new StreamCorruptedException("Unexpected class descriptor type: " + type);
		} 
	} 
 
	private Class<?> loadClass(String className) throws ClassNotFoundException
	{ 
		return mClassLoader.loadClass(className);
	} 
} 
5
CodeRank

Related Java 8 StreamCorruptedException Questions & Answers:

See Code Examples for Java 8 StreamCorruptedException Methods: