Skip to content

Instantly share code, notes, and snippets.

@iobee
iobee / testJavaWriteFilePerformance.java
Created December 11, 2017 12:28
testJavaWriteFilePerformance
char[] chars = new char[100*1024*1024];
Arrays.fill(chars, 'A');
String text = new String(chars);
long start = System.nanoTime();
BufferedWriter bw = new BufferedWriter(new FileWriter("/tmp/a.txt"));
bw.write(text);
bw.close();
long time = System.nanoTime() - start;
System.out.println("Wrote " + chars.length*1000L/time+" MB/s.");
@iobee
iobee / ClassLocationUtils.java
Created March 1, 2016 02:35
Locate class jar
package com.ridge.util;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
/**
* @author : chenxh