Instantly share code, notes, and snippets.

View JsonData.java
import java.io.Serializable;
/**
* 功能描述:工具类
*
* <p> 创建时间:May 14, 2018 7:58:06 PM </p>
*/
public class JsonData implements Serializable {
/**
View 加解密工具类.java
package com.diaolizhi.mybatisdemo.utils;
import com.diaolizhi.mybatisdemo.domain.User;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import java.util.Date;
View LazySingleton.java
package chapter3;
/**
* @program: studythread2
* @description: 懒汉式单例模式
* @author: diaolizhi
* @create: 2018-11-13 12:39
**/
public class LazySingleton {
View SynchronizedDemo.java
package chapter3;
/**
* @program: studythread2
* @description: synchronized Demo
* @author: diaolizhi
* @create: 2018-11-13 10:29
**/
public class SynchronizedDemo {
View note.java
btnFinish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intentToFinish = new Intent(WizardThree.this, FinishActivity.class);
//重点是下面这一句
intentToFinish.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
intentToFinish.putExtra("setting", setting);
startActivity(intentToFinish);
WizardThree.this.finish();
}
View Activity.java
//
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, WizardOne.class);
intent.putExtra("setting", setting);
startActivityForResult(intent, 1);
}
});
View timer.cs
public Form1()
{
//TimerCallback 是委托类型,可以关联一个形参为 Object 的函数
TimerCallback timerCallback = new TimerCallback(timeUpdate);
//Timer 每隔 1000ms 调用委托
System.Threading.Timer timer = new System.Threading.Timer(timerCallback, "", 0, 1000);
}
public void timeUpdate(Object obj)
View getcookies.cs
//不知道为什么有些 cookie 获取不到,只能通过这种方式解决
//这一次的用法是,先在 WebBrowser 登录贴吧网页版,然后将 http://tieba.baidu.com/mo/ 传给 GetCookie 方法
//就可以获取到所有 cookie
//需要引入 System.Net 并 using System.Net;
//下面这段代码作为内部类,如何使用在后面
internal static class CookieReader
{
/// <summary>
View random.java
public static void shuffle(Object[] a) {
//判断数组 a 是否可以转为整型数组
validateNotNull(a);
int n = a.length;
for (int i = 0; i < n; i++) {
int r = i + uniform(n-i); // between i and n-1
Object temp = a[i];
a[i] = a[r];
a[r] = temp;
}
View close.cs
private void Form2_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = (MessageBox.Show("Sure?",
"Exit",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) == DialogResult.Yes);
DialogResult result = MessageBox.Show("提示", "确定退出吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{