需求:前端展示数据,全国城市的坐标…
学习java一段时间了,今天写来一个即时通信的小例子练手在其过程中也学到了一些知识拿出来和大家分享,请路过的各位大神多多赐教... 好了下面讲一下基本的思路: 首先,编写服务器端的程序,简单点说吧就是在服务上开启一个线程循环等待客户端的连接,为每一个连接到服务器的Socket 创建一个实例存放在集合中,然后使用InputSteam读取从客户端发过来的数据然后转发给除自己之外的所有的客户端 然后是客户端,首先开启一个线程连接都服务器端,循环监听服务器发送回来的数据 这里要说一下为了明确是谁发出的消…
本篇文章主要讲解在微信小程序中,如何利用微信自带的api(wx.getLocation())结合百度地图的逆地址解析api来获取当前所在城市名. 实现起来也比较简单,步骤为: 1--利用微信小程序接口 wx.getLocation() 获取当前经纬度.使用简单,具体可以参照微信小程序api. https://mp.weixin.qq.com/debug/wxadoc/dev/api/location.html#wxopenlocationobject 2--拿到经纬度之后,通过微信的wx.req…
一,File创建文件 File file = new File("D:" + File.separator + "yi.txt"); 代码示例: package com.hbut.io; import java.io.File; import java.io.IOException; public class FileDemo { public static void main(String[] args) { File file = new File("…
有一次工作中,要根据多个参数确定一个值(车辆事件),确定一个值需要的参数大部分的属性名称是相同的,少部分是独有的,但是参数的值几乎都是不同的: 因为参数太多,if-else写起来就太不优雅了,可以参考用工厂模式和策略模式优化过多的IF-ELSE:https://www.cnblogs.com/theRhyme/p/10339382.html: 这里就作为一个Java Eunm的例子: 也可以再数据库中配置一张表,对应的字段就是数据库表中对应的列,属性的值就是对应的行记录,判断是哪种事件就可以用查…
package test; import java.io.File; public class FileName { /** * @param args */ public static void main(String[] args) { // 举例: String fName =" G:\\Java_Source\\navigation_tigra_menu\\demo1\\img\\lev1_arrow.gif "; // 方法一: File tempFile =new File…
public static final String POEM= "Twas brilling, and the slithy toves\n" + "Did gyre and gimble in the wabe.\n"+ "All mimsy were the borogoves,\n" + "And the mome rathsoutgrable.\n\n"+ "Beware the Jabberwork, m…
package com.wjy.main; import java.io.Console; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import com.wjy.reflect.Student; public class TestMain { public static void main(String args[]){ try{ Class<?> cls=Class.forName(&quo…
1. 声明一个变量person指向一个引用对象, 然后将这个person添加到集合list中, 然后将变量person指向null, 问:list中添加的person变成null了吗? import java.util.ArrayList; import java.util.List; public class TestRef { public static void main(String[] args) { Person p = new Person("张三"); List<…
举例:String fName =" G:\Java_Source\navigation_tigra_menu\demo1\img\lev1_arrow.gif " 方法一: 1 File tempFile =new File( fName.trim()); 2 String fileName = tempFile.getName(); 方法二: String fName = fName.trim(); String fileName = fName.subString(fName.l…