Java判断操作系统是Windows或Mac,获取用户路径

该Java程序首先获取操作系统名称,如果是Windows则执行特定操作,然后获取用户家目录路径。接着,它处理截图压缩,根据是否为iOS设备调整压缩比例。最后,创建结果报告。
摘要由CSDN通过智能技术生成

package other;

public class CheckSystem {

public static void main(String[] args) {

String osName = System.getProperty("os.name");

System.out.println(osName); //Windows 10

if (osName.startsWith("Windows")) {

System.out.println("Windows");

} else {

System.out.println("Mac");

}

String userName = System.getProperty("user.home"); //获取用户的路径 C:\Users\jeff.xie

System.out.println(userName);

String path ="D:\\Project\\Program\\screenshots";

String flag ="android";

CompressPicture compressPicture = new CompressPicture();

//String flag =System.getProperty("mobile").toUpperCase();

double compressPercent=0.2;

if(flag.contains("IOS")) compressPercent =0.4;

String compressScreenShotsPath =compressPicture.changeByDir( path,0,0,compressPercent);

GetScreenShot getScreenShot = new GetScreenShot();

getScreenShot.create_result_report(compressScreenShotsPath, flag);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值