如何回滚System.setProperty的改变

671
2024/6/27 21:12:10
栏目: 深度学习
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

要回滚System.setProperty的改变,可以通过保存原始属性值,在需要时重新设置回去。例如:

// 保存原始属性值
String originalValue = System.getProperty("propertyKey");

// 设置新属性值
System.setProperty("propertyKey", "newValue");

// 需要回滚时重新设置原始属性值
System.setProperty("propertyKey", originalValue);

这样就可以实现回滚System.setProperty的改变。

辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读: System.setProperty和System.getProperties区别