皮皮网

【js算命源码】【dnf顺图源码】【android桌面插件源码】writeDouble源码

时间:2024-12-28 19:42:26 来源:adbshell源码

1.java如何实现从远程ip和端口接收数,最好能够给出源码,js算命源码类似于tcp/ip网络调试助手。dnf顺图源码
2.java源代码 求大神 明天就要上机

writeDouble源码

java如何实现从远程ip和端口接收数,android桌面插件源码最好能够给出源码,dede捧腹网源码类似于tcp/ip网络调试助手。解除防沉迷源码

       import java.net.*;

       import java.io.*;

       public class TestSocketClient {

        public static void main(String[] args) {

        try {

        Socket socket = new Socket(".0.0.1", );

        System.out.println("请输入计算式:");

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String s1 = br.readLine();

        DataOutputStream dos = new DataOutputStream(socket.getOutputStream());

        DataInputStream dis = new DataInputStream(socket.getInputStream());

        dos.writeUTF(s1);

        dos.flush();

        double s = dis.readDouble();

        System.out.println("计算结果:" + s);

        dis.close();

        dos.close();

        socket.close();

        } catch (IOException e) {

        e.printStackTrace();

        System.out.println("连接出错");

        System.exit(-1);

        }

        }

       }

       服务器端:

       import java.net.*;

       import java.io.*;

       public class TestSocketServer {

        public static void main(String[] args) {

        try {

        ServerSocket ss = new ServerSocket();

        Socket socket = ss.accept();

        DataOutputStream dos = new DataOutputStream(socket.getOutputStream());

        DataInputStream dis = new DataInputStream(socket.getInputStream());

        String s = null;

        if ((s = dis.readUTF()) != null) {

        System.out.println("接收到的算式:" + s);

        double result = 0;

        String[] sarr1 = s.split("[\\+\\-\\*\\/]");

        double a = Double.parseDouble(sarr1[0].trim());

        double b = Double.parseDouble(sarr1[1].trim());

        String[] sarr2 = s.split("^(-?\\d+)(\\.\\d+)?");

        char c = sarr2[1].trim().charAt(0);

        switch (c) {

        case '+':

        result = a + b;

        break;

        case '-':

        result = a - b;

        break;

        case '*':

        result = a * b;

        break;

        case '/':

        result = a / b;

        break;

        default:

        break;

        }

        dos.writeDouble(result);

        dos.flush();

        }

        dis.close();

        dos.close();

        socket.close();

        } catch (IOException e) {

        e.printStackTrace();

        System.exit(-1);

        }

        }

       }

java源代码 求大神 明天就要上机

       package com.uisftec;

       import java.io.Serializable;

       public class TestScores implements Serializable {

        private double[] testScores;

        public TestScores(double[] testScores) {

        this.testScores = testScores;

        }

        public double getAverageScore() {

        double sum = 0.0d;

        for (int i = 0; i < testScores.length; i++) {

        sum += testScores[i];

        }

        return sum / testScores.length;

        }

       }

       package com.uisftec;

       public class InvalidTestScore {

        public InvalidTestScore(double[] testScores) {

        if (testScores == null) {

        throw new IllegalArgumentException("数组为空");

        }

        for (int i = 0; i < testScores.length; i++) {

        if (testScores[i] < 0 || testScores[i] > ) {

        throw new IllegalArgumentException("数组中包含的test Score不在0~这个范围内");

        }

        }

        }

       }

       package com.uisftec;

       import java.io.DataOutputStream;

       import java.io.File;

       import java.io.FileInputStream;

       import java.io.FileNotFoundException;

       import java.io.FileOutputStream;

       import java.io.IOException;

       import java.io.ObjectInputStream;

       import java.io.ObjectOutput;

       import java.io.ObjectOutputStream;

       public class TestScoresSerialize {

        public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {

        // 创建5个对象

        TestScores testScores1 = new TestScores(new double[] { 1.0, 2.0 });

        TestScores testScores2 = new TestScores(new double[] { 5.0, 2.0 });

        TestScores testScores3 = new TestScores(new double[] { .0, .0 });

        TestScores testScores4 = new TestScores(new double[] { .0, .0 });

        TestScores testScores5 = new TestScores(new double[] { .0, .0 });

        // 创建数组

        TestScores[] testScores = new TestScores[] { testScores1, testScores2, testScores3, testScores4, testScores5 };

        // 写入到D盘testScores.dat

        ObjectOutput out = new ObjectOutputStream(new FileOutputStream("d:\\testscores.dat"));

        for (TestScores testScores6 : testScores) {

        out.writeObject(testScores6);

        }

        // D盘STOUT

        File file = new File("D:\\STDOUT");

        // 创建输出留

        DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(file));

        // 创建读取d盘序列化对象

        ObjectInputStream in = new ObjectInputStream(new FileInputStream("d:\\testscores.dat"));

        // 打印平均分并写入到D盘STDOUT

        TestScores testScores8 = (TestScores) in.readObject();

        System.out.println(testScores8.getAverageScore());

        outputStream.writeDouble(testScores8.getAverageScore());

        TestScores testScores9 = (TestScores) in.readObject();

        outputStream.writeDouble(testScores9.getAverageScore());

        System.out.println(testScores9.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        TestScores testScores = (TestScores) in.readObject();

        System.out.println(testScores.getAverageScore());

        outputStream.writeDouble(testScores.getAverageScore());

        // 关闭流

        out.close();

        in.close();

        outputStream.close();

        }

       }

推荐资讯
特朗普提名外交使節 美職籃球隊老闆和真人秀製片人在列

特朗普提名外交使節 美職籃球隊老闆和真人秀製片人在列

crtmpserver源码分析

crtmpserver源码分析

sgk接口源码_sgk接口查询

sgk接口源码_sgk接口查询

openssl源码结构

openssl源码结构

俄聯邦航空運輸署:阿航墜機事故當天烏軍對俄城市進行襲擊

俄聯邦航空運輸署:阿航墜機事故當天烏軍對俄城市進行襲擊

开源oj源码_uoj开源

开源oj源码_uoj开源

copyright © 2016 powered by 皮皮网   sitemap