This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 拷贝List | |
resps = BeanConverterUtil.copyList(EduExamPapers, EduExamPaperResp.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"database/sql" | |
"encoding/json" | |
"fmt" | |
_ "github.com/go-sql-driver/mysql" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#define MAX 100000 | |
typedef struct | |
{ | |
int arr[MAX]; | |
}NUMBER; | |
/* 读取数字字符串,并转为int数组保存 */ | |
void read(NUMBER *add_num) | |
{ |
NewerOlder