个人博客:https://www.zhoujunwen.com
能力说明:
精通JVM运行机制,包括类生命、内存模型、垃圾回收及JVM常见参数;能够熟练使用Runnable接口创建线程和使用ExecutorService并发执行任务、识别潜在的死锁线程问题;能够使用Synchronized关键字和atomic包控制线程的执行顺序,使用并行Fork/Join框架;能过开发使用原始版本函数式接口的代码。
阿里云技能认证
详细说明2022年11月
2020年10月
2020年02月
2019年11月
Google Chrome 下载文件的时候有个小 bug,文件名中不能包含逗号(,),而且字符编码需要改为 ISO 8859-1。
可以用下面的方式尝试一下:
String fileName = URLEncoder.encode(mixedFileNameArr[1],"UTF-8");
new String(fileName.getBytes("UTF-8"), "ISO8859-1");
百灵,凌云
家里冷,不敢吹空调,只能在脚下放一个暖风机。
首先在 Mysql8 中,默认“LOAD DATA LOCAL INFILE”是OFF,即关闭的一起。需要在服务端开启:
SET @@GLOBAL.local_infile=1;
在客户端命令行中使用,正如你所说,需要添加--local-infile=1
参数,但是在JDBC中,貌似没有这个限制。只是需要使用超级用户权限。同时,你需要注意,你的文件必须是MySQL服务系统所在机器中的文件,而不是本地客户机器中中文件(或者说并不是你应用部署系统的文件,除非你的应用和MySQL在同一个机器上)。
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/foobar", "root", "password");
Statement stmt = con.createStatement();
String sql =
"load data infile 'c:/temp/some_data.txt' \n" +
" replace \n" +
" into table prd \n" +
" columns terminated by '\\t' \n" +
" ignore 1 lines";
stmt.execute(sql);
kafka的目录,kfka的端口,zk的端口,zk的目录分别配置就可以了呀。
The transient
keyword in Java is used to indicate that a field should not be part of the serialization (which means saved, like to a file) process.
From the Java Language Specification, Java SE 7 Edition, Section 8.3.1.3. transient Fields:
Variables may be marked transient to indicate that they are not part of the persistent state of an object.
For example, you may have fields that are derived from other fields, and should only be done so programmatically, rather than having the state be persisted via serialization.
Here's a GalleryImage
class which contains an image and a thumbnail derived from the image:
class GalleryImage implements Serializable
{
private Image image;
private transient Image thumbnailImage;
private void generateThumbnail()
{
// Generate thumbnail.
}
private void readObject(ObjectInputStream inputStream)
throws IOException, ClassNotFoundException
{
inputStream.defaultReadObject();
generateThumbnail();
}
}
In this example, the thumbnailImage
is a thumbnail image that is generated by invoking the generateThumbnail
method.
The thumbnailImage
field is marked as transient
, so only the original image
is serialized rather than persisting both the original image and the thumbnail image. This means that less storage would be needed to save the serialized object. (Of course, this may or may not be desirable depending on the requirements of the system -- this is just an example.)
At the time of deserialization, the readObject method is called to perform any operations necessary to restore the state of the object back to the state at which the serialization occurred. Here, the thumbnail needs to be generated, so the readObject
method is overridden so that the thumbnail will be generated by calling the generateThumbnail
method.
For additional information, the Discover the secrets of the Java Serialization API article (which was originally available on the Sun Developer Network) has a section which discusses the use of and presents a scenario where the transient
keyword is used to prevent serialization of certain fields.
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.4</version>
</dependency>
不知道为什么,显示不了xml标签,我截图如下:
localhost也叫local ,正确的解释是:
本地服务器
127.0.0.1在windows等系统的正确解释是:本机地址(本机服务器)
127.0.0.1 localhost
localhot(local)是不经网卡传输,它不受网络防火墙和网卡相关的的限制。 127.0.0.1 是通过网卡传输,依赖网卡,并受到网络防火墙和网卡相关的限制。
一般设置程序时本地服务用localhost是最好的,localhost不会解析成ip,也不会占用网卡、网络资源。
有时候用localhost可以,但用127.0.0.1就不可以的情况就是在于此。猜想localhost访问时,系统带的本机当前用户的权限去访问,而用ip的时候,等于本机是通过网络再去访问本机,可能涉及到网络用户的权限。
这里有具体的排查思路你可以参考一下:https://help.aliyun.com/knowledge_detail/84083.html?spm=5176.13394938.0.0.6ff04d57onSrct
感觉这个和你现在遇到的情况很相似。
2003-不能连接到MySQL服务器上的’119.23.168.137’(100060"未知错误")
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
FLUSH PRIVILEGES;
通过修改表来实现远程:
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
不管是BIO还是NIO,其实都是通过轮训的方式来实现socket服务的。下面几个demo或许有助于你:
public class BIODemo {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = new ServerSocket();
serverSocket.bind(new InetSocketAddress("0.0.0.0", 8888), 50);
Socket socket;
while ((socket = serverSocket.accept()) != null) {
InputStream is = socket.getInputStream();
byte[] data = new byte[1024];
is.read(data);
System.out.println(new String(data, UTF_8));
OutputStream out = socket.getOutputStream();
out.write(data);
socket.close();
}
}
}
public class NIODemo {
public static void main(String[] args) throws IOException {
ServerSocketChannel serverSocketChannel = ServerSocketChannel.open();
serverSocketChannel.bind(new InetSocketAddress("0.0.0.0", 8888), 50);
serverSocketChannel.configureBlocking(false);
Selector selector = Selector.open();
serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT);
while (true) {
selector.select();
Set<SelectionKey> selectionKeys = selector.selectedKeys();
Iterator<SelectionKey> iterator = selectionKeys.iterator();
while (iterator.hasNext()) {
SelectionKey key = iterator.next();
if (!key.isValid()) {
continue;
}
if (key.isAcceptable()) {
ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
SocketChannel clientChannel = serverChannel.accept();
clientChannel.configureBlocking(false);
clientChannel.register(selector, SelectionKey.OP_READ);
} else if (key.isReadable()) {
ByteBuffer buffer = ByteBuffer.wrap(new byte[1024]);
SocketChannel clientChannel = (SocketChannel) key.channel();
int read = clientChannel.read(buffer);
if (read == -1) {
key.cancel();
clientChannel.close();
} else {
buffer.flip();
clientChannel.write(buffer);
}
}
}
iterator.remove();
}
}
}
如果你需要更详细的更深入的了解,可以参考我的这篇文章 JAVA中BIO、NIO、AIO的分析理解 https://developer.aliyun.com/article/726698?spm=a2c6h.13148508.0.0.1d844f0eaWNdWj
很棒!!!
不支持的操作异常,根据提示,当前某个类不允许子类覆盖。检查你的业务代码,是不是集成了final的类,或者有哪些集合是不可修改的。
没有其他错误信息,也看不出具体的问题。
从两个方面来说吧。第一个是编码安全,第二个是网络设备安全。
#
做参数的获取http://app.ym.163.com/ym/reg/view/index 这个163域名企业邮箱注册地址,根据提示一步一步操作。需要在你的域名解析服务中增加一条MX
的配置,值为mx.ym.163.com
。
http://app.ym.163.com/ym/help/help-hmail.html#3.6 这是域名验证的方法。
特殊符号&通过urlencode编码试试看。 &
编码后为 %26
。
上面各位都已经回答的很好了,再补充一个人,国内go语言方面的大神:郝林。
郝林是 GoHackers 技术社群发起人,畅销榜书籍《Go并发编程实战》的作者,前轻松筹大数据负责人。13年软件开发从业经验,做过银行、电信软件和互联网社交产品。从2012年底开始关注Go语言,对Go语言和 Docker 技术都情有独钟,是Go语言的忠实拥护者。
不过,郝林一直活跃在 GoHackers 微信群和知识星球,如果你需要进入 GoHackers 技术群,你可以加我,我征询一下大佬,看能不能把你加进去,微群是免费的,知识星球可能是收费的,我没太关注过。