admin

该用户没有分享资料


admin

java中调用windows_cmd或linux下命令

java程序中执行windows下cmd命令很简单,代码所示:

Runtime.getRuntime().exec(command);//command是命令内容,如”dir”

当然由于java的平台无关性,linux的命令也可照常执行.

下面代码的的作用是执行一条命令,返回结果的字符串形式:

/**
* @param command cmd命令
* @return 命令执行后的字符
*/
private String runCmd(String command){
Process p;
try {
p = Runtime.getRuntime().exec(command);
InputStream inStream = new BufferedInputStream(p.getInputStream());
StringBuffer buffer = new StringBuffer();
for (;;)
{
int c = inStream.read();
if (c == -1)
break;
buffer.append((char) c);
}
String outputText = new String(buffer.toString().getBytes(“ISO-8859-1″));
inStream.close();
return outputText.trim();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

本文地址:http://www.yaronspace.cn/blog/index.php/archives/256

windows下cmd中tasklist命令详解

tasklist命令和linux下的top命令很相似,不过有一点不同是top命令可以查看某个进程的cpu占用率,而tasklist只能显示某进程已使用cpu的时间,不过可以手工计算,不过不爽的是精度只是到s秒级别,误差很大的。

tasklist例子:

tasklist/v   显示所有的详细信息

tasklist /nh /fi \” imagename eq cmd.exe\” /v /fo table    :显示图像名为”tomcat6.exe”的进程的有关信息

更多 >

java中String转化为Date

需求:已知String  startTime = “12:00:00″;String endTime = “13:10:44″;计算endTime-startTime的差值,这里如果手工算的话比较麻烦,可以用java.text.DateFormat来将String的startTime和endTime类型转化为Date型,然后再getTime()获得对应时间的毫米数,最后相减即可。 更多 >

8 Web Trends to Watch in 2010

  1. social media
  2. business
  3. mobile
  4. marketing
  5. search
  6. SEO
  7. web design & development
  8. software

Social Media

  • Twitter integration and apps were king in 2009 and are here to stay. Either you integrate or you perish
  • Tumblr is successful and growing in the shadow of Twitter, when Twitter finally loses steam will Tumblr be the new darling?
  • Market consolidation in social media leaving only a few major players on the scene: Twitter, Facebook and who else?
  • Social news (Digg, Reddit) and bookmarking (Delicious) will become obsolete. Already the first wave of social media that is social news and bookmarking lose against Twitter.
  • Social browsing (StumbleUpon etc.) is already dead. There were more than a dozen of social browsing services in 2008. Most of them are dead or on hiatus already. More to follow.

Business

  • We’ll witness a demise or hiatus of most startups without critical mass of users as the money runs out
  • We can expect a proliferation of premium and freemium business models as venture capital stays scarce
  • Companies and brands will have to develop a social media strategy in 2010 to stay afloat
  • With business accounts and data access selling like hotcakes and additional revenue sources Twitter will become profitable in 2010 already

Mobile

  • We’ll see a smartphone systems death match as the market isn’t big enough for all the often incompatible systems we have right now.
  • Apple will be losing market share. The iPhone still looks like years ago. They don’t even have a netbook yet. They can’t rely on cult tactics forever.
  • Phones and calls for free thanks Google: Google prepares the real Google Phone combining Google Voice and Gizmo5 VoIP to offer free calls.

Marketing

  • We’ll see less bullshit and more substance in the online marketing field. As the Web matures more and more people become too savvy to get fooled.
  • Advertising replaced on the Web by “ad content” that is non promotional content about the brand, company or products: Less banners more reports.

Search

  • Real time search will go prime time for everyone, not just the search geeks and early adopters
  • Google and Bing will keep on copying each other in order to capitalize on the search advertising market
  • Advanced personalization will lead to your own personal search results for most people rendering ranking checks useless

SEO

  • SEO is becoming ubiquitous, everybody does it (BBC etc.) and in 2010 those who don’t will fail to compete
  • More SEO experts will return underground again inspite of ubiquitous SEO due to wide spread prejudice of the ignorant against the trade
  • Like it or not but we’ll see more jQuery pop ups due to their high conversion rate. Thanks to @rhyswynne for the suggestion

Web Design & Development

  • Mobile apps will continue to boom and optimized web pages for mobile use will become common place finally
  • HTML5 and CSS3 will allow web designers to offer extra features possible backed by graceful degradation in oder to support for older browsers
  • YouTube censorship spawns an open source and DIY video embedding counter movement. We already witness it but in 2010 you’ll look like a noob using YouTube on your site


Blogging

  • Blogs get even more authoritative and accepted, becoming the “old media” of the Web
  • Quick and clean miniblogging (Tumblr, Posterous etc.) establish a lively sphere between Twitter-like microblogging and blogging. @richardbaxter of SEOGadget agrees about Posterous continuous growth
  • Video content finally gets the importance we expected for years now with growing band width etc.


Software

  • There will be more cloud computing and web based software or rather webware around and people will use it more often
  • Most notably Google Docs will convince more users of the Microsoft Office desktop edition to switch
  • At the same time Google Chrome OS will be competing successfully with Windows at least on netbooks

Eclipse下使用Ant

目前的Eclipse都集成了ant,本文图示如何在eclipse下使用ant。
1.新建Java Project-新建Java文件HelloWorld.java
HelloWorld.java
package example;
public class HelloWorld {
public static void main(String[] args) {
System.out.println(“Hello World”);
}
}
2.在工程根目录下新建build.xml 更多 >

ant用法简介

Ant是什么?
Ant是一种基于Java和XML的build工具。

主页:http://ant.apache.org/index.html

详情:http://blog.csdn.net/lx999501/archive/2006/06/30/856024.aspx

本文地址:http://www.yaronspace.cn/blog/index.php/archives/244

新学两个linux下的命令-pgrep+pkill

我的理解:

pgrep *** = ps -ef | grep ***

pkill *** = ps -ef | kill ***

本文地址:http://www.yaronspace.cn/blog/index.php/archives/242

Linux与Windows 共享文件-使用Samba

以前实习的时候mentor在windows下建立网络映射时,以为很简单,今天常识了一把,原来是需要linux下第三方软件的支持的-samba,才能建立linux和windows下的磁盘映射。

参考资料:http://linux.vbird.org/linux_server/0370samba.php#server_share【鸟哥私房菜】

http://www.linuxsir.org/main/?q=node/158#0.1【简体中文】

本文地址:http://www.yaronspace.cn/blog/index.php/archives/239

过滤注释的正则表达式

过滤/** ….*/注释格式的正则表达式
至于//还不太清楚,愿高人指点!

\/\*(\s|.)*?\*\/

本文地址:http://www.yaronspace.cn/blog/index.php/archives/237

java-追加内容到文件末尾的几种常用方法

代码实现是我从别处拷的,记录下

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.RandomAccessFile;

/**
* 描述:追加内容到文件末尾
* @author Administrator
*
*/
public class WriteStreamAppend {
/**
* 追加文件:使用FileOutputStream,在构造FileOutputStream时,把第二个参数设为true
*
* @param fileName
* @param content
*/
public static void method1(String file, String conent) {
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file, true)));
out.write(conent);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

/**
* 追加文件:使用FileWriter
*
* @param fileName
* @param content
*/
public static void method2(String fileName, String content) {
try {
// 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件
FileWriter writer = new FileWriter(fileName, true);
writer.write(content);
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}

/**
* 追加文件:使用RandomAccessFile
*
* @param fileName
*            文件名
* @param content
*            追加的内容
*/
public static void method3(String fileName, String content) {
try {
// 打开一个随机访问文件流,按读写方式
RandomAccessFile randomFile = new RandomAccessFile(fileName, “rw”);
// 文件长度,字节数
long fileLength = randomFile.length();
// 将写文件指针移到文件尾。
randomFile.seek(fileLength);
randomFile.writeBytes(content);
randomFile.close();
} catch (IOException e) {
e.printStackTrace();
}
}

public static void main(String[] args) {
System.out.println(“start”);
method1(“c:/test.txt”, “追加到文件的末尾”);
System.out.println(“end”);
}

}

本文地址:http://www.yaronspace.cn/blog/index.php/archives/235