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
StringBuffer sb = new StringBuffer(); | |
File f = new File(file); | |
if (f.exists()) { | |
System.out.println("file not exist"); | |
try { | |
BufferedReader br = new BufferedReader(new InputStreamReader( | |
new FileInputStream(f))); | |
while ((s = br.readLine()) != null) { | |
sb.append(s); | |
} |
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(); |
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
/** | |
* TIKA-332: Check for meta http-equiv tag with charset info in | |
* HTML content. | |
* <p> | |
* TODO: Move this into core, along with CharsetDetector | |
*/ | |
private String getEncoding(InputStream stream, Metadata metadata) throws IOException { | |
stream.mark(META_TAG_BUFFER_SIZE); | |
char[] buffer = new char[META_TAG_BUFFER_SIZE]; | |
InputStreamReader isr = new InputStreamReader(stream, "us-ascii"); |
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
/* MARK 使用Matcher.quoteRepalcement()过滤特殊字符 */ | |
matchRes.appendReplacement(sb, Matcher.quoteReplacement(replacement)); | |
// 格式化日期 | |
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()); | |
public void getNdayBefor(int n){ | |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |
Calendar now = Calendar.getInstance(); | |
now.set(Calendar.DATE, now.get(Calendar.DATE) - n); |
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
from datetime import datetime | |
import time | |
now = datetime.now() | |
u = str(long(time.mktime(now.timetuple()))) |
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> | |
#include <string.h> | |
#include <math.h> | |
#define MAX 100 | |
/** | |
一个特殊的国家忌讳7这个数字,所有包含7的数字他们都不用, | |
改用下一个数字,比如7他们用8代替,17用19代替。 | |
给定这个国家的数字,如何编程翻译成我们用的数字。 | |
**/ |
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> | |
/* | |
首先定义运算"swap":从数组中移除一个元素,然后放在该数组的尾部。 | |
用最少的“swaps"将数组排序。 | |
比如,[3 1 2 4],最少需要[3 1 2 4]->[1 2 4 3]->[1 2 3 4] | |
程序的输入为小于65536的正整数,数组长度小于100 | |
*/ |
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 mine.forfun; | |
public class InfiniteRecursion { | |
@Override | |
public String toString(){ | |
return " InfiniteRecursion address: " + this; // + super.toString(); | |
} | |
public static void main(String[] args) { |
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 static java.lang.Math.*; | |
import static java.lang.System.out; | |
public class StaticImport { | |
public static void main(String args[]){ | |
double r = cos(PI * theta); | |
out.println(r); | |
} | |
} |
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" | |
void move(int id, char f, char t){ | |
printf("move %d from %c to %c\n", id, f, t); | |
} | |
void hanoi(int n, char a, char b, char c){ | |
if(n==1){ | |
move(n, a, c); | |
}else{ |
OlderNewer