我正在.properties使用Spring 从文件加载属性属性,如下所示:
file: elements.properties
base.module.elementToSearch=1
base.module.elementToSearch=2
base.module.elementToSearch=3
base.module.elementToSearch=4
base.module.elementToSearch=5
base.module.elementToSearch=6
Run Code Online (Sandbox Code Playgroud)
spring xml文件
file: myapplication.xml
<bean id="some"
class="com.some.Class">
<property name="property" value="#{base.module.elementToSearch}" />
</bean>
Run Code Online (Sandbox Code Playgroud)
还有我的Class.java
file: Class.java
public void setProperty(final List<Integer> elements){
this.elements = elements;
}
Run Code Online (Sandbox Code Playgroud)
但是在调试时,参数元素只将最后一个元素放入列表中,因此,有一个值为"6"的元素列表,而不是包含6个元素的列表.
我尝试了其他方法,例如仅添加值,#{base.module}但它在属性文件中找不到任何参数.
解决方法是在elements.properties文件中包含以逗号分隔的列表,例如:
base.module.elementToSearch=1,2,3,4,5,6
Run Code Online (Sandbox Code Playgroud)
并将其用作String并解析它,但是有更好的解决方案吗?
我使用以下代码在java上传过敏字体:
private Font loadFont(final String path) {
Font font = null;
InputStream fontFile = null;
fontFile = FontLoaderClass.class.getResourceAsStream(path);
if (fontFile != null) {
try {
font = Font.createFont(Font.PLAIN, fontFile);
} catch (FontFormatException e) {
LOGGER.error("Error with font format {}", e);
} catch (IOException e) {
LOGGER.error("Error accessing font {}", e);
}
}
return font;
}
Run Code Online (Sandbox Code Playgroud)
正确加载字体:
http://www.fontsquirrel.com/fonts/Aller
字体设置为所有".font"更改java应用程序的默认设置,但在Linux中显示正确但Windows不是.
private Font buildFont(final String key, final int size) {
Font f = loadFont(ALLER_LT_FONT_PATH);
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(f);
if (f == null) {
f = (Font) …Run Code Online (Sandbox Code Playgroud) 以下是我所面临问题的近似值.
认为我们有一些密码验证器和一些规则.
public interface RuleChecker{
//Checks for a password strenght, returns 10
//for strong or 0 for soft password.
int check(String pass);
}
Run Code Online (Sandbox Code Playgroud)
然后我们有几个实现,我们的服务只接受密码,如果它超过8分.
public class NoCheck implements RuleChecker {
public int check(String pass){return 10;}
}
public class LengthCheck implements RuleChecker{
...
}
public class AlphanumericCheck implements RuleChecker{
...
}
public class AlphaAndLenghtCheckAdapter implements RuleChecker{
...
}
Run Code Online (Sandbox Code Playgroud)
但出于测试目的,我们希望在应用程序中实现一个Web服务,我们可以"管理"这些规则,并选择要拥有的规则.
public class PasswordCheckService{
private RuleChecker checker;
@Inject
public PasswordCheckService(final RuleChecker checker){
this.checker = checker;
}
public boolean checkPassword(String password){
return checker.check(password) > …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我连接到笔记本电脑的设备连接到我的docker实例.
具体来说,我有4个设备(两个iphone,两个android),我希望能够启动4个docker实例并将每个设备连接到一个实例.
我期望做的就像在ubuntu中那样简单
docker run --privileged -v /dev/bus/usb:/dev/bus/usb -d -P my-android:0.0.1
Run Code Online (Sandbox Code Playgroud)
但我的主机操作系统是Mac OS X,也是我正在创建的实例,因为我需要访问仪器工具.
但到目前为止,我读到在mac os x下,设备直接连接虽然没有安装usb.
这是我搜索iphone设备时得到的:
iPhone USB:
Type: Ethernet
BSD Device Name: en6
IPv4:
Configuration Method: DHCP
IPv6:
Configuration Method: Automatic
Proxies:
Exceptions List: *.local, 169.254/16
FTP Passive Mode: Yes
Run Code Online (Sandbox Code Playgroud)
您知道如何将设备连接到docker实例吗?
谢谢!!!!
我正在尝试为安全的https连接实现webclient.我导入了服务器证书并将其添加到java密钥库.但是当我尝试运行客户端时,我得到以下例外: -
Oct 18, 2013 3:25:25 PM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging WARNING: Interceptor for
{http://tempuri.org/}Service#{http://tempuri.org/}GetUserInformation has thrown exception,
unwinding now org.apache.cxf.interceptor.Fault: Could not send Message.
at
org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:64)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:272)
at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:565)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:474)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:377)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:330)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:135)
at $Proxy29.getUserInformation(Unknown Source)
at
org.tempuri.ServiceSoap_ServiceSoap_Client.main(ServiceSoap_ServiceSoap_Client.java:78)
Caused by: java.io.IOException: IOException invoking
myurl/**/**/asmx: The https URL hostname does not
match the Common Name (CN) on the server certificate in the client's truststore. Make sure
server certificate is correct, or to disable this check …Run Code Online (Sandbox Code Playgroud) 我想创建一种使用3x3高斯内核模糊24位图像的方法.
我得到了以下的东西.
3x3高斯内核:
A是原始图像,B是结果图像.
B(i,j) =
1/16 * A(i-1,j-1) +1/8 * A(i,j-1) +1/16 * A(i+1,j-1) +1/8 * A(i-1,j) +1/4 * A(i,j) +1/8 *A(i+1,j) +1/16 * A(i-1,j+1) +1/8 * A(i,j+1) +1/16 * A(i+1,j+1)
Run Code Online (Sandbox Code Playgroud)
方法:
public static BufferedImage gaussianBlur(Image img)
Run Code Online (Sandbox Code Playgroud)
其中img是输入图像的参考变量.
返回值是结果图像的对象的地址.
我应该将图像分成9个部分来实现这个方法吗?
我们使用java原语'byte' fileInputStream.read(byte)等读取和写入二进制文件.在另一个例子中我们看到byte[] = String.getBytes().一个字节只是8位值.为什么我们byte[]用来读二进制文件?从文件或字符串读取后,字节值包含什么?