需要api来获取我当前进程或应用程序在CPU中的CPU和内存使用情况.我得到了一个API来获取完整的系统的CPU使用率,但我需要特殊处理.(getSystemCpuLoad
的OperatingSystemMXBean
接口)
提前致谢
我正在使用这个log4j.properties
log4j.rootCategory=Info, A1
# A1 is a DailyRollingFileAppender
log4j.appender.A1=org.apache.log4j.DailyRollingFileAppender
log4j.appender.A1.file=D:/MyWeb.log
log4j.appender.A1.datePattern='.'yyyy-MM-dd
log4j.appender.A1.append=true
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-22d{dd/MMM/yyyy HH:mm:ss} - %m%n
Run Code Online (Sandbox Code Playgroud)
我想在Date Wise Order中显示日志,所以我正在使用DailyRollingFileAppender
.但问题是这个日志文件目前无法容纳太多数据(这意味着当天发出大量请求)它会丢失以前的日志数据
我试着使用这个选项MaxFileSize
:
log4j.appender.A1.MaxFileSize=10MB
Run Code Online (Sandbox Code Playgroud)
但是在服务器控制台上,它给出了MaxFileSize
不支持该属性的错误.
请告诉我是否有任何其他方式日志显示日期,它可以保存尽可能多的数据.
假设我有一个数字123.我需要看看我是否得到所有数字1到9,包括0.数字123有三个数字:1,2和3.然后我乘以2得到246(我得到数字2,4,6).然后我乘以3得到369.我继续进行增量乘法,直到得到所有数字.
我的方法如下:
public int digitProcessSystem(int N) {
String number = Integer.toString(N);
String [] arr = number.split("");
// List <Integer> arr2 = new ArrayList<>();
for (Integer i = 0; i < arr.length; i++) {
try {
arr2[i] = Integer.parseInt(arr[i]);
} catch (NumberFormatException e) {
}
}
count =0;
boolean contains = IntStream.of(arr2).anyMatch(x -> x == 1|| x==2 ||x == 3|| x==4|| x == 5|| x==6 ||x == 7|| x==8||x == 9|| x==0);
}
Run Code Online (Sandbox Code Playgroud)
我真的不知道如何继续为上面第一条路径中不匹配的数字做布尔值,因为我肯定会得到上面布尔搜索中所有数字中的任何一个.如果某些特定数字存在且有些不是这样我可以将实际数字乘以搜索第一次试验中未找到的数字,我该如何得到; 就像我在开始时定义的那样.
我有一个ScheduleContainer
对象列表,在流中,每个元素都应该被输入到类型中ScheduleIntervalContainer
.有办法做到这一点吗?
final List<ScheduleContainer> scheduleIntervalContainersReducedOfSameTimes
final List<List<ScheduleContainer>> scheduleIntervalContainerOfCurrentDay = new ArrayList<>(
scheduleIntervalContainersReducedOfSameTimes.stream()
.sorted(Comparator.comparing(ScheduleIntervalContainer::getStartDate).reversed())
.filter(s -> s.getStartDate().withTimeAtStartOfDay().isEqual(today.withTimeAtStartOfDay())).collect(Collectors
.groupingBy(ScheduleIntervalContainer::getStartDate, LinkedHashMap::new, Collectors.<ScheduleContainer> toList()))
.values());
Run Code Online (Sandbox Code Playgroud) 我通过jsoup访问网页时获得404.但是通过浏览器访问时页面加载正常.
几天前我能通过jsoup访问该页面.但现在它抛出404.试图添加用户代理,超时等但没有运气.
在Firebug中,我收到404请求,但页面在浏览器中加载正常.
不确定页面如何在浏览器中呈现,而不是通过Java程序呈现.
Document doc = Jsoup.connect("http://example.com/stock.php?"+quote).userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36")
.timeout(1000*7).get();
Run Code Online (Sandbox Code Playgroud)
在执行Java程序时,获得以下错误:
org.jsoup.HttpStatusException:HTTP错误提取URL.状态= 404,URL = http://example.com/stock.php?AAA
at org.jsoup.helper.HttpConnection $ Response.execute(HttpConnection.java:537)
如果需要更多信息,请告诉我.
第一个陈述有效但不是第二个给出以下误差,为什么?
java.util.Arrays.asList(1,2,3,4,5).stream()
.map(n -> n+1)
.collect(Collectors.toList());
List<Integer> list = IntStream.rangeClosed(1, 10)
.map(n -> n + 1)
.collect(Collectors.toList());
Run Code Online (Sandbox Code Playgroud)
错误:
Type mismatch: cannot convert from Collector<Object,capture#5-of ?,List<Object>>
to Supplier<R>
Run Code Online (Sandbox Code Playgroud) package com.n;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
public class S implements Serializable {
private static final long serialVersionUID = 1L;
transient int i;
public static void main(String[] args) throws Exception, IOException {
ObjectOutputStream oos =
new ObjectOutputStream(new FileOutputStream("c:\\jav\\f.txt"));
S obj1 = new S(10);
oos.writeInt(obj1.i);
oos.writeObject(obj1);
ObjectInputStream ois =
new ObjectInputStream(new FileInputStream("c:\\jav\\f.txt"));
System.out.println("Object contains >> " + ois.readObject());
System.out.println("Transient variable written separately yields >> i ="
+ ois.readInt());
}
public S(int i) {
this.i …
Run Code Online (Sandbox Code Playgroud) 在我的肥皂应用程序中,我正在使用apache cxf。
这是我的代码,它将数据提交到服务器。
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.ws.security.wss4j.DefaultCryptoCoverageChecker;
import org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
SpringBusFactory bf = new SpringBusFactory();
URL busFile = Submission.class.getResource(WSSEC_XML);
File f = new File(busFile.getPath());
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
DefaultCryptoCoverageChecker coverageChecker = new DefaultCryptoCoverageChecker();
coverageChecker.setSignBody(true);
coverageChecker.setSignTimestamp(true);
coverageChecker.setEncryptBody(true);
coverageChecker.setSignAddressingHeaders(true);
MyClaimservice service = new MyClaimservice();
Myclaims port = service.getMyClaimsSoap11();
BindingProvider provider = (BindingProvider) port;
provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ENDPOINT_ADDRESS);
provider.getRequestContext().put(BindingProvider.SOAPACTION_URI_PROPERTY, SOAP_ACTION);
Client client = ClientProxy.getClient(port);
client.getOutInterceptors().add(new LoggingOutInterceptor());
client.getInInterceptors().add(new LoggingInInterceptor());
client.getInInterceptors().add(new WSS4JInInterceptor(getInProps())); …
Run Code Online (Sandbox Code Playgroud) 我想definde的的OnAction的安信永巴顿在完成scalafx,但我不能让它工作.
package App.Desktop
import javafx.event.EventHandler
import scalafx.event.ActionEvent
import scalafx.scene.control.Button
class Window() {
btn_YES.onAction = (event: ActionEvent) =>
new EventHandler[ActionEvent] {
override def handle(event: ActionEvent) {
/*Do something*/
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我做到了这一点,但是我收到了一个错误
Error: type mismatch;
found : scalafx.event.ActionEvent => javafx.event.EventHandler[scalafx.event.ActionEvent]
required: javafx.event.EventHandler[javafx.event.ActionEvent]
btn_YES.onAction = (event: ActionEvent) => new EventHandler[ActionEvent]
Run Code Online (Sandbox Code Playgroud)
我也尝试使用javafx.event.ActionEvent
而不是scalafx
但它也不起作用.
任何线索?
谢谢
我正在使用 Selenium Webdriver 和核心 Java 自动化一个测试用例,其中单击一个按钮,我会收到浏览器级别的通知“显示带有允许和阻止选项的通知”。单击“允许”按钮后,我想验证来自以及单击它们的网络推送通知的内容。是否有人知道如何做到这一点通过selenium.Notifications会是这样的Facebook铬通知
java ×7
java-8 ×3
algorithm ×1
core ×1
cpu-usage ×1
cxf ×1
heap-memory ×1
java-stream ×1
javafx ×1
jsoup ×1
log4j ×1
scala ×1
scalafx ×1
selenium ×1
soap ×1
web-services ×1
webdriver ×1
ws-security ×1