后台用java写的,java虚拟机安卓版apk主机选择windows操作系统还是Linux操作系统

Java 识别操作系统是Windows还是Linux亦或者者是Mac os - 送吗网
Java 识别操作系统是Windows还是Linux亦或者者是Mac os
天香阁主 阅读:8
1.原理????????非常简单,调使用System.getProperty()方法,参数传入"os.name"就可。2.代码
public static void main(String[] args) {
String osName = System.getProperty("os.name");
System.out.println(osName);
if (osName.startsWith("Mac OS")) {
} else if (osName.startsWith("Windows")) {
// windows
// unix or linux
}3.效果Linux效果.pngwindows效果.png4.总结????????由于笔者没有Mac电脑,所以就没有Mac系统执行的效果图;另外,此方法可可以是有bug的,不过这个bug影响的是操作系统版本号的判断,为什么这么说呢?由于笔者的windows执行环境是windows 10系统,输出版本号却是8.1(从“windows效果”图能很显著看出),不过不论怎么, System.getProperty("os.name")是完全能判断出操作系统是Windows还是Linux亦或者者是Mac os。&>&java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)
java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)
上传大小:1.05MB
java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)
综合评分:0
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有0条
VIP会员动态
热门资源标签
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
jason_deng
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*投诉人姓名:
*投诉人联系方式:
*版权证明:
*详细原因:
java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)博客访问: 35891
博文数量: 56
博客积分: 0
博客等级: 民兵
技术积分: 588
注册时间:
分类: Java 22:48:49
使用方法:
&&&&&&&&OSinfo.isWindows()
&&&&&&&&OSinfo.isLinux()
添加相应jar包到Java项目即可, &jar包:(保留作者信息)
& & & jar下载位置:http://pan.baidu.com/s/1sjuKGLR
&* @author: &&&&
&* @dateTime:&&&&
下午3:55:43
&* @description:
public enum EPlatform {
&&&&&&&& Any("any"),
Linux("Linux"),
Mac_OS("Mac OS"),
Mac_OS_X("Mac OS X"),
Windows("Windows"),
OS2("OS/2"),
Solaris("Solaris"),
SunOS("SunOS"),
MPEiX("MPE/iX"),
HP_UX("HP-UX"),
AIX("AIX"),
OS390("OS/390"),
FreeBSD("FreeBSD"),
Irix("Irix"),
Digital_Unix("Digital Unix"),
NetWare_411("NetWare"),
OSF1("OSF1"),
OpenVMS("OpenVMS"),
Others("Others");
&&&&private EPlatform(String desc){
&&&&&&&&this.description = desc;
&&&&public String toString(){
&&&&&&&&return description;
&&&&private String description;
&* @author
&* @author: &&&&
&* @dateTime:&&&&
下午3:54:07
&* @description:
package com.myhexin.tool;
public class OSinfo {
&&&&private static String OS = System.getProperty("os.name").toLowerCase();
&&&&private static OSinfo _instance = new OSinfo();
&&&&private EPlatform platform;
&&&&private OSinfo(){}
&&&&public static boolean isLinux(){
&&&&&&&&return OS.indexOf("linux")>=0;
&&&&public static boolean isMacOS(){
&&&&&&&&return OS.indexOf("mac")>=0&&OS.indexOf("os")>0&&OS.indexOf("x")<0;
&&&&public static boolean isMacOSX(){
&&&&&&&&return OS.indexOf("mac")>=0&&OS.indexOf("os")>0&&OS.indexOf("x")>0;
&&&&public static boolean isWindows(){
&&&&&&&&return OS.indexOf("windows")>=0;
&&&&public static boolean isOS2(){
&&&&&&&&return OS.indexOf("os/2")>=0;
&&&&public static boolean isSolaris(){
&&&&&&&&return OS.indexOf("solaris")>=0;
&&&&public static boolean isSunOS(){
&&&&&&&&return OS.indexOf("sunos")>=0;
&&&&public static boolean isMPEiX(){
&&&&&&&&return OS.indexOf("mpe/ix")>=0;
&&&&public static boolean isHPUX(){
&&&&&&&&return OS.indexOf("hp-ux")>=0;
&&&&public static boolean isAix(){
&&&&&&&&return OS.indexOf("aix")>=0;
&&&&public static boolean isOS390(){
&&&&&&&&return OS.indexOf("os/390")>=0;
&&&&public static boolean isFreeBSD(){
&&&&&&&&return OS.indexOf("freebsd")>=0;
&&&&public static boolean isIrix(){
&&&&&&&&return OS.indexOf("irix")>=0;
&&&&public static boolean isDigitalUnix(){
&&&&&&&&return OS.indexOf("digital")>=0&&OS.indexOf("unix")>0;
&&&&public static boolean isNetWare(){
&&&&&&&&return OS.indexOf("netware")>=0;
&&&&public static boolean isOSF1(){
&&&&&&&&return OS.indexOf("osf1")>=0;
&&&&public static boolean isOpenVMS(){
&&&&&&&&return OS.indexOf("openvms")>=0;
&&&&&* 获取操作系统名字
&&&&&* @return 操作系统名
&&&&public static EPlatform getOSname(){
&&&&&&&&if(isAix()){
&&&&&&&&&&&&_instance.platform = EPlatform.AIX;
&&&&&&&&}else if (isDigitalUnix()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Digital_Unix;
&&&&&&&&}else if (isFreeBSD()) {
&&&&&&&&&&&&_instance.platform = EPlatform.FreeBSD;
&&&&&&&&}else if (isHPUX()) {
&&&&&&&&&&&&_instance.platform = EPlatform.HP_UX;
&&&&&&&&}else if (isIrix()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Irix;
&&&&&&&&}else if (isLinux()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Linux;
&&&&&&&&}else if (isMacOS()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Mac_OS;
&&&&&&&&}else if (isMacOSX()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Mac_OS_X;
&&&&&&&&}else if (isMPEiX()) {
&&&&&&&&&&&&_instance.platform = EPlatform.MPEiX;
&&&&&&&&}else if (isNetWare()) {
&&&&&&&&&&&&_instance.platform = EPlatform.NetWare_411;
&&&&&&&&}else if (isOpenVMS()) {
&&&&&&&&&&&&_instance.platform = EPlatform.OpenVMS;
&&&&&&&&}else if (isOS2()) {
&&&&&&&&&&&&_instance.platform = EPlatform.OS2;
&&&&&&&&}else if (isOS390()) {
&&&&&&&&&&&&_instance.platform = EPlatform.OS390;
&&&&&&&&}else if (isOSF1()) {
&&&&&&&&&&&&_instance.platform = EPlatform.OSF1;
&&&&&&&&}else if (isSolaris()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Solaris;
&&&&&&&&}else if (isSunOS()) {
&&&&&&&&&&&&_instance.platform = EPlatform.SunOS;
&&&&&&&&}else if (isWindows()) {
&&&&&&&&&&&&_instance.platform = EPlatform.Windows;
&&&&&&&&}else{
&&&&&&&&&&&&_instance.platform = EPlatform.Others;
&&&&&&&&return _instance.platform;
&&&&&* @param args
&&&&public static void main(String[] args) {
&&&&&&&&System.out.println(OSinfo.getOSname());
阅读(908) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
请登录后评论。Free. Cross-platform. Open source. A developer platform for building
Supported on Windows, Linux, and macOS
for Windows, Linux, macOS, and Docker.
Use a single codebase to build native
for iOS, Android, and Windows.
Create beautiful and compelling
for Windows and macOS.
for the most popular desktops, phones, and consoles.
Add vision algorithms, speech processing, predictive models,
to your apps.
Make , with native support for the Raspberry Pi and other single-board computers.
You can write your .NET apps in C#, F#, or Visual Basic.
One Platform
Your skills, code, and favorite libraries apply anywhere you use .NET.
Our step-by-step tutorial will help you get .NET running on your computer.
Supported on Windows, Linux, and macOS扫一扫体验手机阅读
java.io写文件在linux中出现中文乱码之解决
& & 最直接的办法就是在使用java io写文件时强制进行转码。最后是这样写的:& & & & & //得到系统默认的encoding码
&&&&&&&&&&&String fileEncode = System.getProperty("file.encoding");
&&&&&&&&&&File outFile = new File(ConfHelper.getConf("OperLogPath"));
&&&&&&&&&&&&&&&&&&&&&&OutputStreamWriter ow = new OutputStreamWriter(
&&&&&&&&&&&&&&new FileOutputStream(outFile, true), fileEncode);
&&&&&&&&&&&&&&&&&&&&&&String logStr = "[" + DateUtil.formatDate(new Date())
&&&&&&&&&&&&&&+ "]用户Id=" + loginUser.getId() + ",用户名称="
&&&&&&&&&&&&&&+ loginUser.getUsername() + " 修改彩绣类别 typeid="
&&&&&&&&&&&&&&+ typeid + " 为 [catgery=" + catgery + ",restype="
&&&&&&&&&&&&&&+ restype + ",ressubtype=" + ressubtype + "]\r\n";
&&&&&&&&&&&&&&&&&&&&&&ow.write(new String(logStr.getBytes("UTF-8"), fileEncode));
&&&&&&&&&&&&&&&&&&&&&&ow.close();& & 注意到有些资料说还有一种解决方案就是,修改linux的系统编码字符集:& & & & &修改/etc/sysconfig/i18n 这个文件
& & & & &将LANG="zh_CN.UTF-8"修改为:
&& & & & &LANG="zh_CN.GBK"
&& & & & &保存并关闭,运行下面的命令使配置生效:
&& & & & &shell& source /etc/sysconfig/i18n但是,这就完全改变了服务器的编码,可能会引起其它效应,所以应慎重。我没有尝试,有需要的话,可以一试。
<span type="1" blog_id="551057" userid='
71篇文章,90W+人气,0粉丝
大数据时代的微服务之路
¥51.00495人订阅}

我要回帖

更多关于 口碑好的java培训机构 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信