Skip to content

Instantly share code, notes, and snippets.

View chocotan's full-sized avatar
🐶

小羽 chocotan

🐶
  • Shanghai, China
View GitHub Profile
package br.com.delta.tileproxy;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_LENGTH;
import static io.netty.handler.codec.http.HttpHeaders.Names.CONTENT_TYPE;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpContent;
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpPost hp = new HttpPost(UPLOAD_URL);
CloseableHttpResponse response = null;
String result = null;
MultipartEntityBuilder multiPartEntityBuilder = MultipartEntityBuilder.create();
multiPartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
// 可以直接addBinary
multiPartEntityBuilder.addPart("image", new FileBody(fileToUpload, ContentType.create("image/png", Consts.UTF_8), FILENAME));
multiPartEntityBuilder.setCharset(Consts.UTF_8);
@chocotan
chocotan / WebAppInitializer.java
Created July 8, 2015 06:49
sprint mvc without xml
package cn.datafox.web.config;
import org.sitemesh.config.ConfigurableSiteMeshFilter;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.FilterRegistration;
package cn.zto.ordercore.validate;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@chocotan
chocotan / DownloadHelper.java
Created April 20, 2015 01:02
下载的中文文件名支持
/**
* 设置让浏览器弹出下载对话框的Header.
* 根据浏览器的不同设置不同的编码格式 防止中文乱码
* @param fileName 下载后的文件名.
*/
public static void setFileDownloadHeader(HttpServletRequest request,HttpServletResponse response, String fileName) {
try {
//中文文件名支持
String encodedfileName = null;
String agent = request.getHeader("USER-AGENT");
package io.hime.client
import java.awt.BorderLayout
import java.awt.GridLayout
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import java.awt.event.MouseAdapter
import java.text.SimpleDateFormat
import javax.swing.BorderFactory
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
package io.loli.util.image;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
package io.loli.test;
import java.util.Observable;
public class HeadHunter extends Observable {
private String newJob;
public String getNewJob() {
return newJob;
import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
public class FilesWalk {