当前位置:首页

Linux环境下tar命令压缩解压缩tar.gz文件速记

解压缩,假设输出文件夹为yourdir。sudo tar -zxvf yourfile.tar.gz -C yourdi压缩,假设待压缩文件夹为yourdir。sudo tar -zcvf res....阅读全文

JavaScript中数字与字符串的相互转换

字符串转整型parseIn
<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">

	var number = parseInt("123")
	alert(number + 1);
	
</script>

</head>
	
<body>
</body>
</html>

字符串转float型parseFloa
<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">

	var number = parseFloat("11.23")	
	alert(number);
	
</script>

</head>
	
<body>
</body>
</html>

如果解析结果不是数字,则结果值是NaN,可以通过isNaN函数来判断。
<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">

	var number = parseInt("zzz")
	
	if(isNaN(number))
	{
		alert("error");
	}
	
</script>

</head>
	
<body>
</body>
</html>

数字转字符串
<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">

	var number = 123;
	alert(number.toString()+"!");
	
</script>

</head>
	
<body>
</body>
</html>

阅读全文

Java中数组,List和Set的互相转换

数组转换成List
String[] strArray = new String[] {"1", "2"};
List <String> list = Arrays.asList(strArray );
List转换成数组:
List list = new ArrayList();
list.add("1");
list.add("2");
String[] strArray = (String[])list.toArray(new String[list.size()]);
数组转换成Set:
String[] strArray = {"a", "b"};	
Set set = new HashSet(Arrays.asList(strArray));
Set转换成数组:
Set set = new HashSet<String>();
set.add("a");
set.add("b");

Object[] objArray = set.toArray();
或:
String[] strArray = (String[])set.toArray(new String[0]);
或:
String[] strArray = (String[])set.toArray(new String[set.size()]);
List转换成Set:
List<String> list = new ArrayList<String>();
Set set = new HashSet(list);
Set转换成List:
Set<String> set = new HashSet<String>();
set.add("a");
set.add("b");
	
String[] strArray = set.toArray(new String[set.size()]);

阅读全文

Java中整型、double、float型数字与字符串的相互转换

整型转换成字符串,方式1
int nValue = 15;
String str = Integer.toString(nValue);
整型转换成字符串,方式2:
int nValue = 15;
String str = String.valueOf(nValue);
字符串转换成整型:
String str = "15";
int nValue = Integer.parseInt (str);
double转换成字符串:
double dValue = 1.234;
String str = String.valueOf(dValue);
字符串转换成double:
String str = "1.234";
double dValue = Double.parseDouble(str);
float转换成字符串:
float fValue = 1.234f;
String str = String.valueOf(dValue);
字符串转换成float:
String str = "1.234";
float fValue = Float.parseFloat(str);
阅读全文

返回页首返回页尾