ITeye博客

Light Up Your Dream

FJJJ8 · 共 112 篇文章

12个数组操作方法

下面是stackoverflow中关于数组方法的相关问题中,获得最多票数的12个数组操作方法。 声明一个数组 Java代码 复制代码 1.String aArray = new String; 2.String bArray = {"a","b","c", "d", "e"}; 3.String cArray = new String{"a","b","c","d","e"}; 输出一个数组 Java代码 复制代码 1.int intArray = { 1, 2, 3, 4, 5 }; 2.String intArrayString = Arrays.toString(intArray); …

2017-05-05T17:39:05Z · 编程语言 · 评论(0)

Shell中 done 后接一个重定向<

Shell中while循环的done 后接一个重定向< means that the While读文件的方法: 第一步: 将文件的内容通过管道(|)或重定向(<)的方式传给while 第二步: while中调用read将文件内容一行一行的读出来,并付值给read后跟随的变量。变量中就保存了当前行中的内容。 例如读取文件/sites/linuxpig.com.txt 1)管道的方式: cat /sites/linuxpig.com.txt |while read LINE do echo $LINE done 当然也可以将cat /sites/linuxpig.com.txt 写成一些复杂一些…

2016-03-15T10:39:31Z · 编程语言 · 评论(0)

Oracle 相应时间计算

1、获得时间差毫秒数: select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('2008-04-30 23:59:59' , 'yyyy-mm-dd hh24-mi-ss')) * 24 * 60 * 60 * 1000) 相差豪秒数 FROM DUAL; 相差豪秒数 ---------- 86401000 2、获得相差秒数: select ceil((To_date('2008-05-02 00:00:00' , 'yyyy-mm-dd hh24-mi-ss') - To_date('…

2016-02-26T15:01:28Z · 数据库 · 评论(0)

ORACLE 中DECODE和 CASE WHEN函数使用方式

decode是pl/sql语法,只能在oracle中使用, case when是标准SQL的语法,哪儿都能用,也就是说移植性更强. decode像是case when的精简版, DECODE只能用做相等判断,但是可以配合sign函数进行大于,小于,等于的判断;CASE可用于=,>=,<,<=,<>,is null,is not null 等的判断; 当要实现的功能比较简单时,用decode方便,简洁. decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 该函数的含义如下: IF 条件=值1 THEN RETURN(翻译值1) ELSIF 条件=值2 THEN …

2016-02-26T14:56:52Z · 数据库 · 评论(0)

Get details about long running operations

http://stackoverflow.com/questions/23071771/how-to-create-a-slow-sql-query http://www.oraclerecipes.com/monitoring/monitor-long-running-oracle-operations/ https://community.oracle.com/thread/905506?customTheme=otn

2015-10-19T11:38:01Z · 编程语言 · 评论(0)

Logger.getLogger()和LogFactory.getLog() and logging.Logger

Logger来自log4j自己的包。如果用Logger.getLogger,需要一个log4j的jar包. LogFactory来自common-logging包。如果用LogFactory.getLog,你可以用任何实现了通用日志接口的日志记录器替换log4j,而程序不受影响。apache的common-logging包是通用日志接口,通过这个中间层,你可以随便指定到底用哪个日志系统。增加系统的灵活性。若log4j它不存在, commons-logging 会另行选择其它的日志实现类。 这样保证了程序中不一定要使用log4j这个日志文件了 增强灵活性的理由: 1)首先在 classpath…

2015-04-24T11:32:21Z · 编程语言 · 评论(0)

ssh logon without password in Linux servers

ssh 无密码登录要使用公钥与私钥。linux下可以用用ssh-keygen生成公钥/私钥对。 有机器A(192.168.1.100),B(192.168.1.151)。现想A通过ssh免密码登录到B。 1.在A机下生成公钥/私钥对,使用ssh-keygen生成一对密钥,存放在用户目录的~/.ssh下。 [chabc@a ~]$ ssh-keygen -t rsa -P '' ssh-keygen代表生成密钥;-t(注意区分大小写)表示指定生成的密钥类型;-P表示密码,-P '' 就表示空密码,也可以不用-P参数,这样就要三车回车,用-P就一次回车。 它在/home/chabc下生成.ssh…

2015-01-22T11:00:29Z · 操作系统 · 评论(0)

Log4j knowledge note

Log4j pattern format explain: %m 输出代码中指定的消息 %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL %r 输出自应用启动到输出该log信息耗费的毫秒数 %c 输出所属的类目,通常就是所在类的全名 %t 输出产生该日志事件的线程名 %n 输出一个回车换行符,Windows平台为“rn”,Unix平台为“n” %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyyy MMM dd HH:mm:ss,SSS},输出类似:2002年10月18日 22:10:28,921 %l 输出日志事件的…

2015-01-15T14:58:47Z · 编程语言 · 评论(0)

BAT read file and write file

@echo off setlocal enableextensions setlocal enabledelayedexpansion for /f "tokens=1 delims= " %%m in (sys.out) do ( set num=%%m if /i !num! equ 5 ( echo 1 >nsys.out del sys.out && move nsys.out sys.out ) else ( set old=%%m set /a newN=!old!+1 echo !newN! >nsys.out del sys.out && move nsys.out sys.…

2015-01-14T18:17:05Z · 编程语言 · 评论(0)

Linux shell 查看系统开机时间

1: who 命令查看 who -b 查看最后一次系统启动的时间。 who -r 查看当前系统运行时间 [root@server ~]# who -b system boot May 11 09:27 2: last reboot [root@server ~]# last reboot reboot system boot 2.6.9-42.ELsmp Thu May 29 15:25 (00:07) reboot system boot 2.6.9-42.ELsmp Sun May 11 09:27 (18+05:55) wtmp begins Mon May 5 16:18:57 20…

2014-11-10T10:54:26Z · 操作系统 · 评论(0)

Insert characters Into a string in bash

echo "2013abcd07" | sed 's/^\(.\{8\}\)/\1-/' output: 2013abcd-07 it will insert character '-' after 8 characters time=125959 ## expected : 12:59:59 echo ${time:0:2}:${time:2:2}:${time:4:2} Example: input: "abcd" output: ".abcd a.bcd ab.cd abc.d abcd." input=abcd for ((i=0; i<${#input}+1; i++)) do e…

2014-09-25T11:23:30Z · 编程语言 · 评论(0)

Oracle block and session

For reference only. If you've ever gotten a phone call from an annoyed user whose transaction just won't go through, or from a developer who can't understand why her application sessions are blocking each other, you know how useful it can be to identify not just whose lock is doing the blocking, bu…

2014-09-19T18:31:51Z · 编程语言 · 评论(0)

Oracle basic

一、运算符 算术运算符:+ - * / 可以在select 语句中使用 除法: select MOD(65,50) from dual --取余 select trunc( 65/33) from dual -- 取整 trunc (1.9) = 1 select ceil(65/60) from dual -- 取整 ceil(1.1) = 2 Select cast(100*1.0/101 as decimal(18, 2)) -- 0.99 连接运算符:|| select deptno|| dname from dept; 比较运算符:> >= = != < <= like betwe…

2014-09-09T15:46:11Z · 编程语言 · 评论(0)

linux shell获取当前文件的时间

stat -c %y filename | awk '{print $1 $2 $3}' | cut -d "." -f1 | sed -e 's/-//g' -e 's/://g' stat filename | grep Modify | awk '{print $2 $3}' | cut -d "." -f1 | sed -e 's/-//g' -e 's/://g' stat filename | grep Modify | awk '{print $2}' 比系统时间早3min, a=`stat -c %Y filename`;b=`date +%s`;if [ $[ $b - $…

2014-07-11T14:14:41Z · 编程语言 · 评论(0)

linux tar命令

打包:把多个文件变成一个文件,常用tar。 # tar -cf all.tar *.jpg 这条命令是将所有.jpg的文件打成一个名为all.tar的包。 -c是表示产生新的包, -f指定包的文件名。 # tar -rf all.tar *.gif 这条命令是将所有.gif的文件增加到all.tar的包里面去。 -r是表示增加文件的意思。 # tar -uf all.tar logo.gif 这条命令是更新原来tar包all.tar中logo.gif文件。 -u是表示更新文件的意思。 # tar -tf all.tar 这条命令是列出all.tar包中所有文件。 -t是列出文件的意思 # t…

2014-06-16T11:58:00Z · 编程语言 · 评论(0)