4.27 浮躁是学不到东西滴

忘了是啥,很高级的样子

public  class Main {
   public static void main(String[] args) throws Exception {
      Socket socket=new Socket("12.29.09",1000);
      String str="qisong";
      OutputStream os=socket.getOutputStream();
      os.write(str.getBytes());

      InputStream is=socket.getInputStream();
      InputStreamReader isr=new InputStreamReader(is);
      int b;
      while((b=isr.read())!=-1){
         System.out.println((char)b);
      }
      socket.close();
   }
}


public class test {
    public static void main(String[] args)  throws IOException {
        ServerSocket ss=new ServerSocket(1000);
        Socket socket=ss.accept();
        InputStream is=socket.getInputStream();
        InputStreamReader isr=new InputStreamReader(is);
        int b;
        while((b=isr.read())!=-1){
            System.out.println((char)b);
        }
        String str="uuidscisndc";
        OutputStream os=socket.getOutputStream();
        os.write(str.getBytes());
        socket.close();
        ss.close();
    }
}

上传文件到客户端

public  class Main {
   public static void main(String[] args) throws Exception {
    Socket socket=new Socket("128.1.89",1000);
    BufferedInputStream bis=new BufferedInputStream(new FileInputStream("a.ddkd//ada"));
    BufferedOutputStream bos=new BufferedOutputStream(socket.getOutputStream());
    byte[] bytes=new byte[1024];
    int len;
    while((len= bis.read(bytes))!=-1){
       bos.write(bytes,0,len);
    }
    socket.shutdownInput();
    BufferedReader br=new BufferedReader(new InputStreamReader(socket.getInputStream()));
    String line=br.readLine();
      System.out.println(line);
      socket.close();
   }
}


public class test {
    public static void main(String[] args)  throws IOException {
       ServerSocket ss=new ServerSocket(1000);
       Socket socket=ss.accept();
        BufferedInputStream bis=new BufferedInputStream(socket.getInputStream());
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("a\\a.jpg"));
        int len;
        byte[] bytes=new byte[1024];
        while((len= bis.read(bytes))!=-1){
            bos.write(bytes,0,len);
        }
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        bw.write("yes");
        bw.newLine();
        bw.flush();
        socket.close();
        ss.close();
    }
}

解决文件名重复的问题

 public static void main(String[] args) throws Exception {
    String str= UUID.randomUUID().toString().replace("-","*");
       System.out.println(str);
   }

获取构造方法

public  class Main {
   public static void main(String[] args) throws Exception {
  class clazz=Class.forName("demo");
  Constructor[] cons=clazz.getConstructors();
  for(Constructor con:cons){
      System.out.println(con);
  }}
}

获取字节码文件的对象

public  class Main {
   public static void main(String[] args) throws Exception {
       Class ca=Class.forName("demo");
       Field[] fields=ca.getFields();
       for(Field field:fields){
           System.out.println(field);
       }
   }
}

完了,虽然有点水,但是java基础算是基本掌握了(^-^)ovo

扣1送地狱火.......picture

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值