我有文件jar:
myJar/res/endingRule.txt
myJar/wordcalculator/merger/Marge.class
Run Code Online (Sandbox Code Playgroud)
在Marge.java我有代码:
private static final String ENDINGS_FILE_NAME = "res/endingRule.txt";
....
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(ENDINGS_FILE_NAME);
.....
但是在这个inputStream为null之后.如何使用资源?为什么空? 在我的单元测试中,我需要将"workingDir"系统属性设置为Null.
但我不能这样做,因为它给了我NullPointerException:
System.setProperty("workingDir", null);
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我正在使用google-api-translate-java-0.92.jar.
Translate.setHttpReferrer("http://translate.google.com/");
try {
String translation = Translate.execute("arrangement", Language.ENGLISH, Language.UKRANIAN);
System.out.println(translation);
} catch (Exception e) {
System.out.println(e.getMessage());
}
但我只得到一个翻译.我转到http://translate.google.com/页面,它给了我多个翻译.如何从我的代码中获得多个翻译?
我正在使用网络位置提供商.我需要每隔 1小时从我的LocationListener调用一次onLocationChanged方法.这是我的代码:
MyLocationListener locationListener = new MyLocationListener();
locationMangaer.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3600000, 0,locationListener);
Run Code Online (Sandbox Code Playgroud)
但它不起作用.我onLocationChanged
经常打电话.
我必须使用哪些参数?
我用Eclipse.我为我的项目设置了一些环境变量.我可以从我的java代码中获取它System.getProperty("SOME_VAR")
吗?
如何从Eclipse中的java代码中获取环境变量?
我使用Magnolia CMS和Blossom.
当我向我的类添加注释时,我得到这样的东西:
-source 1.3不支持注释(使用-source 5或更高版本来启用注释)
@Template(value ="Blossom Template")*
Spring注释(如@Controller)也不编译.我的错误在哪里?
我的pom.xml依赖项:
<dependencies>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-blossom</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-admininterface</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-taglib-cms</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-taglib-utility</artifactId>
<version>4.3.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud) java ×6
android ×1
annotations ×1
ant ×1
jar ×1
magnolia ×1
maven-2 ×1
resources ×1
spring ×1
translation ×1