[java]代码库
package com.meili.func;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import org.json.JSONException;
import org.json.JSONObject;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import net.sourceforge.htmlunit.corejs.javascript.ObjArray;
public class test3 {
public static void main(String[] args) throws AWTException, JSONException {
JSONObject json = new JSONObject();
json.put("city", "Mumbai");
json.put("country", "India");
String output = json.toString();
System.out.println(output);
}
public static void pritn(int a,String ... args){
System.out.println("10"=="10");
String x = "30";
for(int i = 0;i<args.length;i++){
System.out.print(args[i]);
System.out.print(x);
System.out.println("aa2");
}
}
private static void windowCoordinatesClick(int x, int y) {
Robot robot = null;
try {
robot = new Robot();
robot.mouseMove(x, y);
robot.delay(2000);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.delay(1000);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
} catch (AWTException e) {
e.printStackTrace();
}
}
public static char fn1(char a)//方法1
{
switch(a)
{
case '一':
return '1';
case '二':
return '2';
case '三':
return '3';
case '四':
return '4';
case '五':
return '5';
case '六':
return '6';
case '七':
return '7';
case '八':
return '8';
case '九':
return '1';
case '零':
return '0';
}
return ' ';
}
/**
* 将阿拉伯数字转中文数字
* @param str
* @return
*/
public static String arabicNumeralsToChinaNum(String str)
{
char hanzi[] = { '零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十' };
char alabo[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
StringBuffer sb = new StringBuffer();
int i = 0;
if (str.length() >= 2) {
if (str.charAt(0) == alabo[1]) {
sb.append("十");
}
if(str.charAt(1) != alabo[0]){
for (; i < hanzi.length; i++) {
if (str.charAt(1) == alabo[i])
return sb.append(hanzi[i]).toString();
}
}
} else {
for (; i < hanzi.length; i++) {
if (str.charAt(0) == alabo[i])
return sb.append(hanzi[i]).toString();
}
}
return sb.toString();
}
/**
* 将中文数字转换为阿拉伯数字
* @param str
* @return
*/
public static StringBuffer chinaNumToArabicNumerals(String str)
{
char hanzi[] = { '零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十' };
char alabo[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
StringBuffer sb = new StringBuffer();
int i = 0;
if (str.length() >= 2) {
for (; i < str.length(); i++) {
for (int j = 0; j < alabo.length; j++) {
if (str.charAt(i) == hanzi[j]) {
sb.append(alabo[j]);
} else if (str.charAt(i) == '十' && str.length() == 1) {
return sb.append("10");
} else if (sb.length() >= 2) {
return sb;
}
}
sb.append("1");
}
} else {
if(str.charAt(i) == '十'){
return sb.append("10");
}
for (; i < hanzi.length; i++) {
if (str.charAt(0) == hanzi[i])
return sb.append(alabo[i]);
}
}
return sb;
}
}
初级程序员
by: 云代码会员 发表于:2016-01-04 17:16:42 顶(1) | 踩(1) 回复
重写
回复评论