「ncsjava开发」NC 编程

博主:adminadmin 2022-11-29 00:56:09 67

本篇文章给大家谈谈ncsjava开发,以及NC 编程对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

请问如何用java程序返回linux中top命令的执行结果

package com.ncs_cyber.util;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileWriter;

import java.io.InputStreamReader;

import java.util.Random;

public class GwUtil {

private static Random r = new Random();

/**

* 功能:执行CMD命令,返回命令结果

*/

public static String execByFile(String cmd) throws Exception {

String filename = null;

StringBuffer sb = new StringBuffer("");

BufferedReader bufferedReader = null;

Process process = null;

File file = null;

r.setSeed(99999);

if (cmd == null) {

return null;

}

try {

String ls_1;

// 生成临时文件,文件名随机

filename = "/tmp/gwtemp" + Long.toString(Math.abs(r.nextLong()))

+ ".sh";

file = new File(filename);

while (file.exists()) {

filename = "/tmp/gwtemp"

+ Long.toString(Math.abs(r.nextLong())) + ".sh";

file = new File(filename);

}

String execmd = new String("sh " + filename);// 执行文件的命令

FileWriter filewriter = new FileWriter(file, false);

filewriter.write("#! /bin/sh");

// Log.debug("do cmd:" + cmd + "\n");

filewriter.write("\n" + cmd + "\n");// 将命令写入文件

filewriter.close();

// Log.debug("run cmd\n");

process = Runtime.getRuntime().exec(execmd); // 执行临时的可执行文件

// Log.debug("run cmd over\n");

// 得到结果

bufferedReader = new BufferedReader(new InputStreamReader(process

.getInputStream()));

while ((ls_1 = bufferedReader.readLine()) != null) {

sb.append(ls_1 + "\n");

}

} catch (Exception e) {

throw new Exception("can not exec the cmd:" + cmd);

} finally { // 清理

try {

filename = null;

if (file != null) {

file.delete();

file = null;

}

if (bufferedReader != null) {

bufferedReader.close();

bufferedReader = null;

}

if (process != null) {

process.destroy();

process = null;

}

} catch (Exception e) {

e.printStackTrace();

}

}

return sb.toString();

}

public static void main(String args[]){

try {

GwUtil.execByFile("top -bn -1/tmp/test.txt;cat/tmp/test.txt");

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

求 成都新电(NCS)Java工程师二面内容! 上周过了笔试(英文技能试题)和一面(英文自我介绍+技术)

呵呵,俺在NCS。。。。

二面没什么了,二面就是经理面试了,问问薪资期望之类的,和你聊聊天,再问问你曾经的工作经历,完了。。。。。也就10多分钟吧。。。。。

好运哦,希望以后能成为同事。

昨天我在B2三楼看见一个面试的,是不是你呀?

成都西南地区比较好的IT公司有哪些?

NOKIA研发中心

nokia-simens研究所

intel

爱立信研究所

摩托罗拉研究所

阿尔卡特研究所

贝尔阿尔卡特研究所

西门子研究所

微软成都研发中心

SAP

IBM研发中心

IBM-ISSC

IBM-IGS

synnex

teleca

simtek

松瀚科技

甲骨文成都研发中心

安捷伦成都研发中心

gameloft

美国新蛋

esmertec

NEC成都研发中心

赛门铁克成都研发中心

conexant

汉略技术(成都)有限公司

富士康(四川)有限公司

GE成都研发中心

思科成都研发中心

MPS

育碧

伟创力研发中心

明瑞

新加坡电讯(NCS)

INTERSERV

芬兰普兰威尔

富士通

迪易通(芬兰)

凌阳科技

Infortrend

美国瞬联软件科技

完美时空

ECWise成都研发中心

飞思卡尔

荷兰凡安德科技

AMD研发中心

埃森哲外包中心

威普罗

symbio成都研发中心

asm成都研发中心

联想全球研发中心

中兴成都研究所

华为成都研究所

金蝶研发中心

用友软件开发中心

盛大研发中心

腾讯研发中心

康佳集团成都研发中心

长虹成都IC设计中心

金山几乎所有的网络游戏研发和营运都在成都。

凹凸科技股份有限公司

阿里巴巴的全球呼叫中心[软件研发基地]

东软集团成都研发中心

神州数码成都研发中心

大唐电信成都研发中心

巨人网络成都研发中心

平安保险集团成都后台IT中心

易方达基金公司成都后台IT中心

太平保险成都后台IT中心

建设银行成都后太IT中心

汇丰银行西部IT中心

太平洋保险成都后太IT中心

泰康人寿成都后太IT中心

工商银行成都后台IT中心

光大银行成都科技研发及后台服务中心

农业银行成都后台IT中心

招商银行成都后台IT中心

交通银行成都后台IT中心

成都锦天科技有限公司

四川虹微技术有限公司

迈普

国腾公司

成都南山之桥技术有限公司

成都成芯公司

友尼森

中芯国际

成都华赛技术有限公司

JAVA简单文件加密 求JAVA源代码

md5加密:

package com.ncs.pki.util;

import java.security.MessageDigest;

import java.security.NoSuchAlgorithmException;

public class MD5Test {

private static MessageDigest digest = null;

public synchronized static final String hash(String data) {

if (digest == null) {

try {

digest = MessageDigest.getInstance("MD5");

} catch (NoSuchAlgorithmException nsae) {

System.err.println(

"Failed to load the MD5 MessageDigest. "

+ "Jive will be unable to function normally.");

nsae.printStackTrace();

}

}

// Now, compute hash.

digest.update(data.getBytes());

return encodeHex(digest.digest());

}

public static final String encodeHex(byte[] bytes) {

StringBuffer buf = new StringBuffer(bytes.length * 2);

int i;

for (i = 0; i bytes.length; i++) {

if (((int) bytes[i] 0xff) 0x10) {

buf.append("0");

}

buf.append(Long.toString((int) bytes[i] 0xff, 16));

}

return buf.toString();

}

public static String test(){

return null;

}

/**

* @param args

*/

public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println(MD5Test.hash("123456"));

}

}

3des加密:

package com.ncs.pki.util;

import java.security.Key;

import java.security.SecureRandom;

import javax.crypto.Cipher;

import javax.crypto.KeyGenerator;

import sun.misc.BASE64Decoder;

import sun.misc.BASE64Encoder;

public class DesEncrypt {

/**

*

* 使用DES加密与解密,可对byte[],String类型进行加密与解密 密文可使用String,byte[]存储.

*

* 方法: void getKey(String strKey)从strKey的字条生成一个Key

*

* String getEncString(String strMing)对strMing进行加密,返回String密文 String

* getDesString(String strMi)对strMin进行解密,返回String明文

*

*byte[] getEncCode(byte[] byteS)byte[]型的加密 byte[] getDesCode(byte[]

* byteD)byte[]型的解密

*/

Key key;

/**

* 根据参数生成KEY

*

* @param strKey

*/

public void getKey(String strKey) {

try {

KeyGenerator _generator = KeyGenerator.getInstance("DES");

_generator.init(new SecureRandom(strKey.getBytes()));

this.key = _generator.generateKey();

_generator = null;

} catch (Exception e) {

e.printStackTrace();

}

}

/**

* 加密String明文输入,String密文输出

*

* @param strMing

* @return

*/

public String getEncString(String strMing) {

byte[] byteMi = null;

byte[] byteMing = null;

String strMi = "";

BASE64Encoder base64en = new BASE64Encoder();

try {

byteMing = strMing.getBytes("UTF8");

byteMi = this.getEncCode(byteMing);

strMi = base64en.encode(byteMi);

} catch (Exception e) {

e.printStackTrace();

} finally {

base64en = null;

byteMing = null;

byteMi = null;

}

return strMi;

}

/**

* 解密 以String密文输入,String明文输出

*

* @param strMi

* @return

*/

public String getDesString(String strMi) {

BASE64Decoder base64De = new BASE64Decoder();

byte[] byteMing = null;

byte[] byteMi = null;

String strMing = "";

try {

byteMi = base64De.decodeBuffer(strMi);

byteMing = this.getDesCode(byteMi);

strMing = new String(byteMing, "UTF8");

} catch (Exception e) {

e.printStackTrace();

} finally {

base64De = null;

byteMing = null;

byteMi = null;

}

return strMing;

}

/**

* 加密以byte[]明文输入,byte[]密文输出

*

* @param byteS

* @return

*/

private byte[] getEncCode(byte[] byteS) {

byte[] byteFina = null;

Cipher cipher;

try {

cipher = Cipher.getInstance("DES");

cipher.init(Cipher.ENCRYPT_MODE, key);

byteFina = cipher.doFinal(byteS);

} catch (Exception e) {

e.printStackTrace();

} finally {

cipher = null;

}

return byteFina;

}

/**

* 解密以byte[]密文输入,以byte[]明文输出

*

* @param byteD

* @return

*/

private byte[] getDesCode(byte[] byteD) {

Cipher cipher;

byte[] byteFina = null;

try {

cipher = Cipher.getInstance("DES");

cipher.init(Cipher.DECRYPT_MODE, key);

byteFina = cipher.doFinal(byteD);

} catch (Exception e) {

e.printStackTrace();

} finally {

cipher = null;

}

return byteFina;

}

public static void main(String[] args) {

System.out.println("des demo");

DesEncrypt des = new DesEncrypt();// 实例化一个对像

des.getKey("MYKEY");// 生成密匙

System.out.println("key=MYKEY");

String strEnc = des.getEncString("111111");// 加密字符串,返回String的密文

System.out.println("密文=" + strEnc);

String strDes = des.getDesString(strEnc);// 把String 类型的密文解密

System.out.println("明文=" + strDes);

}

}

关于ncsjava开发和NC 编程的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-29,除非注明,否则均为首码项目网原创文章,转载请注明出处。