在Android开发中是否有一种方法可以在应用程序的后台运行进程,即使应用程序未处于活动状态.例如,如果用户启动进程,然后点击"主页"按钮,我希望该进程继续在后台运行.
我做了一些寻找,似乎无法弄清楚如何在Silex的URL段中有一个可选参数.所以我目前有这条路线:
/{controller}/{method}/{param}
Run Code Online (Sandbox Code Playgroud)
param通配符是我想要的可选项.所以这个模式会选择像这样的URL
"Controller1/Method1" and "Controller2/Method2/Param"
Run Code Online (Sandbox Code Playgroud)
建议?
我正在JSF网站上工作,我需要一些帮助.我有一个XML文件,我试图通过支持bean读取,但我不知道如何找到它的路径.它位于我的资源文件夹(resources/movies.xml)中.我该怎么做呢?
好吧,所以我正在编写一个Java应用程序来导入一个csv文件,然后遍历结果,并将它们加载到一个数组中.我正在导入文件,因为它没有通过异常.我的问题是,当我尝试计算FileInputStream中的记录数时,我陷入了无限循环.这可能是什么问题.下面是代码:
这是我的类,有一个调用go()的Main方法:
public void go() {
pop = new PopularNames();
popGui = new PopularNamesGui();
String file = popGui.userInput("Enter the correct name of a file:");
pop.setInputStream(file);
pop.getNumberOfNames();
}
Run Code Online (Sandbox Code Playgroud)
这是类PopularNames(pop),在下面的方法中,我将inputStream var设置为新的FileINputStream.文件名由用户提供.
public void setInputStream(String aInputStream) {
try {
inputStream = new Scanner(new FileInputStream(aInputStream));
} catch (FileNotFoundException e) {
System.out.println("The file was not found.");
System.exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)
这是麻烦的方法.我只是循环遍历FileInputStream并计算记录数:
public void getNumberOfNames() {
while (this.inputStream.hasNext()) {
fileDataRows++;
}
}
Run Code Online (Sandbox Code Playgroud)