Skip to content

Instantly share code, notes, and snippets.

//com.google.common.collect.ImmutableMap
Map<String, ArrayList<String>> map1 = ImmutableMap.of("list", new ArrayList<>());
Map<String, Integer> map2 = ImmutableMap.<String, Integer>builder().put("key1", 1).put("key2", 2).build();
import javax.mail.*;
import javax.mail.internet.*;
import java.util.*;
public void postMail( String recipients[ ], String subject, String message , String from) throws MessagingException
{
boolean debug = false;
//Set the host smtp address
Properties props = new Properties();
import java.util.zip.*;
import java.io.*;
/**
* Java学习交流QQ群:589809992 我们一起学Java!
*/
public class ZipIt {
public static void main(String args[]) throws IOException {
if (args.length < 2) {
System.err.println("usage: java ZipIt Zip.zip file1 file2 file3");
System.exit(-1);
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
...
@ggzeng
ggzeng / smal_pic
Last active January 21, 2024 09:40
private void createThumbnail(String filename, int thumbWidth, int thumbHeight, int quality, String outFilename)
throws InterruptedException, FileNotFoundException, IOException
{
// load image from filename
Image image = Toolkit.getDefaultToolkit().getImage(filename);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
// use this to test for errors at this point: System.out.println(mediaTracker.isErrorAny());
public static void fileCopy( File in, File out )
throws IOException
{
FileChannel inChannel = new FileInputStream( in ).getChannel();
FileChannel outChannel = new FileOutputStream( out ).getChannel();
try
{
// inChannel.transferTo(0, inChannel.size(), outChannel); // original -- apparently has trouble copying large files on Windows
// magic number for Windows, 64Mb - 32Kb)
BufferedWriter out = null;
try {
out = new BufferedWriter(new FileWriter(”filename”, true));
out.write(”aString”);
} catch (IOException e) {
// error processing code
} finally {
if (out != null) {
out.close();
}
// 拷贝List
resps = BeanConverterUtil.copyList(EduExamPapers, EduExamPaperResp.class);
package main
import (
"database/sql"
"encoding/json"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
#include<stdio.h>
#define MAX 100000
typedef struct
{
int arr[MAX];
}NUMBER;
/* 读取数字字符串,并转为int数组保存 */
void read(NUMBER *add_num)
{