![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java练习
每天的练习
yx_mengxin
这个作者很懒,什么都没留下…
展开
-
关于class.getClassLoader().getResourceAsStream()和class.getResourceAsStream()的用法
1.class.getResourceAsStream() ①.不加‘ / ’,直接在包的路径下开始寻找,相当于在已经写好的path前面加了一句 /包名/path ②加‘ / ’,就要从classpath的那一层开始找 比如,找到存放编译后的class存放的位置: //文件目录 yx jdbctest com A.class B.class 1.propertie...原创 2020-03-19 17:41:05 · 6822 阅读 · 1 评论 -
tomcat的使用
今天学了一些Tomcat的使用: 首先配置一个临时域名:找到路径:C:\Windows\System32\drivers\etc中的hosts文件,然后在最后一行加入: 127.0.0.1 localhost 127.0.0.1 yiquanchaoren //这里随便取什么名字,这个就是新域名了 然后就是配置下虚拟主机: 在tomcat中的conf目录下的server.xml中加入: ...原创 2020-03-11 22:56:04 · 82 阅读 · 0 评论 -
tcp的一些写法
客户端 public class TcpClient { public static void main(String[] args) { try { //建立一个通道,由于是客户端,所以需要绑定服务端的ip地址和端口 Socket s=new Socket(InetAddress.getByName("19.1.0.0"),8001); InputStream i...原创 2020-03-05 19:39:10 · 304 阅读 · 0 评论 -
udp练习
发送端,也就是客户端 public class UdpSend { public static void main(String[] args) throws Exception { //创建一个通道,因为是发送方,所以端口可以让系统随机配置 DatagramSocket ds=new DatagramSocket(); String str="hello,world"; //指...原创 2020-03-05 12:41:09 · 92 阅读 · 0 评论 -
一种很有意思的写法
直接看代码 public static void main(String[] args) { String[] array = new String[] { "2020-01-06 ", "2020- 01- 09 ", "2020- 05 - 01 ", "2022-02-01", " 2025-01-01" }; for(int i=0;i<arr...原创 2020-03-04 22:21:27 · 144 阅读 · 0 评论 -
每日练习0304
public static void main(String[] args) { String[] array = new String[] { "Like", "image", "aj", "Lambda" }; //Lambda方法的几种不同的应用 //直接传入方法引用 Arrays.sort(array, new Comparator<>() { @Ove...原创 2020-03-04 21:02:56 · 119 阅读 · 0 评论 -
一些inputsream
FileInputStream:是指从文件中获读取数据 ServletInputStream:从HTTP请求读取数据 Socket.getInputStream():从TCP连接读取数据 ByteArrayInputStream:从一个byte类型的变量中读取数据** 同理一些outputstream也是一样 在outputsream中有flush()方法,它的作用是强制将缓冲区的数据输出出来,一...原创 2020-03-03 21:49:12 · 101 阅读 · 0 评论 -
每日练习0303
public class InputStreamTest { public static void main(String[] args) throws IOException{ byte[] data = { 72, 101, 108, 108, 111, 33 }; try (InputStream input = new ByteArrayInput...原创 2020-03-03 18:52:38 · 87 阅读 · 0 评论