我正在开发一个Spring Web项目.
我有一个域类:
com.ciar.seafac.engine.domain.Component
Run Code Online (Sandbox Code Playgroud)
我也在使用@ComponentSpring框架中的注释:
org.springframework.stereotype.Component
Run Code Online (Sandbox Code Playgroud)
我无法在我的类中为这两个类添加import语句.所以,我必须为我的Component类使用完全限定的类名.
有没有其他方法可以做到这一点?我可以知道为什么Eclipse不允许我导入这两个类吗?当我添加两个导入语句并保存类文件.Eclipse只删除了一个.请解释我为什么会这样.
我试图编写一个简单的程序,它将生成随机的3个整数,然后将它们放在数组中,然后将它们连接成一个整数序列,但它会抛出一个错误
这是代码:
int [] kol=new int[3];
for(int j=0;j<3;j++) {
kol[j]=(int)Math.round(Math.random() * 89999) + 10000;
System.out.print(kol[j] +"\n" );
}
String ma=kol[0]+","+kol[1]+","+kol[2]+";";
System.out.println(ma);
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
int b = Integer.parseInt(Integer.toString(kol[0]) + Integer.toString(kol[1]) +
Integer.toString(kol[2]));
System.out.println(b);
Run Code Online (Sandbox Code Playgroud)
但同样的错误:
Exception in thread "main" java.lang.NumberFormatException: For input
at java.lang.NumberFormatException.forInputString(Unknown Source)
string: "715534907077099"
Run Code Online (Sandbox Code Playgroud) 我正在尝试在我的java代码中执行linux命令.它需要更改某些目录的权限.
这是我的尝试:
String Cmd = "echo myPassword | sudo -S chmod 777 -R /home/somePath";
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(Cmd);
Run Code Online (Sandbox Code Playgroud)
String Cmd当我在终端中使用它时,保持的命令工作正常.但是当我在我的代码中使用它时,没有任何反应.没有错误或警告反馈可以帮助我理解我的错误.可能是什么问题?
我需要一些帮助.
我使用此代码将文件夹中的文件作为数组.
String fileDir = Directorty;
File dir = new File(fileDir);
FileFilter fileFilter = new WildcardFileFilter("*.html");
files = dir.listFiles(fileFilter);
Run Code Online (Sandbox Code Playgroud)
但我想写一个文件只包含该文件夹中的文件,而不是路径.结果是:
[C:\Askeladden-17-12-2014\.html, C:\Askeladden-17-12-2014\barnetv.html, C:\Askeladden-17-12-2014\britiskebiler.html, C:\Askeladden-17-12-2014\danser.html, C:\Askeladden-17-12-2014\disipler.html, C:\Askeladden-17-12-2014\donald.html, C:\Askeladden-17-12-2014\ekvator.html, C:\Askeladden-17-12-2014\engelskspraak.html]
Run Code Online (Sandbox Code Playgroud)
但我希望没有这条道路
C:\Askeladden-17-12-2014\
Run Code Online (Sandbox Code Playgroud)
我一直在网上寻找答案,但没有运气.使用这个:
strFiles = Arrays.toString(files);
Run Code Online (Sandbox Code Playgroud)
给出一个字符串,表示为一个数组,每端有[],我无法得到
strFiles.replace("C:\\Askleladden" + date +"\\", "");
Run Code Online (Sandbox Code Playgroud)
上班.
我正在为 Twitter 编写程序。它将读取一条推文并在其中获取主题标签。
问题是,我无法拆分它。例如,"I love #computers so much."在这个中,我只需要获取"computers"部分。
我想通过 using 使用 split 函数,#但它会将句子分成两半,所以仍然不是解决方案。有任何想法吗?