public class ReplaceVowels {
public static void main(String args[]) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the String:");
String str = bf.readLine();
char[] c = new char[str.length()];
for (int i = 0; i < str.length(); i++) {
if (c[i] == 'a' || c[i] == 'e' || c[i] == 'i' || c[i] == 'o'
|| c[i] == 'u') {
System.out.println(str.replace(c[i], '?'));
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么这个str.replace方法不起作用?我该怎么做才能让它发挥作用?
我无法正确地将我的网站集中在一起
当我缩小时,它似乎居中.但对于不缩小的用户来说,它看起来不合适.有什么建议?该网站是使用所有AP div创建的,即使在尝试使用以下内容时它也无法正确居中:
<div align="center">
Run Code Online (Sandbox Code Playgroud) 我有一个包含item1和item2的jcombobox,我也有一个jtextfield ..当我在我的jcombobox上选择item1时,我希望30出现在我的jtextfield上,而如果选择了Item2则为40 ...我该怎么做?
我正在使用SitePrism来测试我的Web应用程序.我有许多扩展的类,SitePrism::Page许多经常使用的HTML片段由匹配的类扩展表示SitePrism::Section
class Login < SitePrism::Section
element :username, "#username"
element :password, "#password"
element :sign_in, "button"
end
class Home < SitePrism::Page
section :login, Login, "div.login"
end
Run Code Online (Sandbox Code Playgroud)
问题是,我正在处理的应用程序基于CMS,其中可以通过基于预定义内容选择模板然后将任意数量的可用组件拖放到页面上来组装页面.
最初的开发人员创建了一个Page Object来镜像每个可用的Template.只要测试数量很少并且我们不得不在我们的功能文件中测试的页面变体太多,这就没问题了.
随着多个测试用例的增加,页面对象开始以惊人的速度增长.
虽然我们可以通过为CMS中可用的每个组件定义Sections并在页面对象中重用它们来轻松地减轻代码重复,但是很多属性很少被使用.
class BlogPost < SitePrism::Page
section :logo, MySite::Components::Logo, '.logo'
section :navigation, MySite::Components::Navigation, '.primary-navigation'
section :header, MySite::Components::BlogHeader, '.header'
section :introduction, MySite::Components::Text, '.text .intro'
# and so on, a lot of dynamic staff that could potentially be dropped onto the page …Run Code Online (Sandbox Code Playgroud) AEM 6.0中的组件可以具有以下属性:cq:template和cq:templatePath.因为我工作并不是两个都需要,但我没有得到这两者之间的确切区别.
我使用以下代码,JLabel用相同的句子替换每0.5秒,但用另一个点.
Runnable r1=new Runnable() {
@Override
public void run() {
while(true){
try {
connectionStatus.setText("Connection Established...");
Thread.sleep(500L);
connectionStatus.setText("Connection Established.");
Thread.sleep(500L);
connectionStatus.setText("Connection Established..");
Thread.sleep(500L);
} catch (InterruptedException ex) {
}
}
}
};
Thread th1=new Thread(r1);
th1.start();
Run Code Online (Sandbox Code Playgroud)
这是使用线程的真正目的吗?这会影响程序的速度吗?如果我正在做的事情是如此愚蠢,还有其他方法来做这些愚蠢的事情吗?
在我的AEM项目的代码看似无关的变化之后,我的捆绑无法解决.检查日志后,我可以看到出现以下错误.
22.04.2015 11:00:18.650 *ERROR* [qtp1266495948-35]
org.apache.felix.http.jetty %bundles.pluginTitle:
Cannot start (org.osgi.framework.BundleException:
Unresolved constraint in bundle my-bundle
...
[caused by: Unable to resolve 401.121: missing requirement [401.121]
osgi.wiring.package; (osgi.wiring.package=sun.reflect.generics.reflectiveObjects)]]
Run Code Online (Sandbox Code Playgroud)
该项目在本地编译得很好,问题只发生在容器试图解决它的捆绑安装之后.
我没有在任何更改中添加任何显式依赖项.项目对象模型与以前相同.这个名字暗示这是一个核心Java包,所以我希望它可以被System bundle公开.
我正在运行JDK 7,这是由AEM支持的,所以不要指望它是JVM兼容性的问题.至少在涉及AEM内部时.
我在我的项目中使用Spring和Hibernate.我用这样的道具
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">${chassis.storage.hibernate.dialect}</prop>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.jdbc.batch_size">${chassis.storage.hibernate.batch_size}</prop>
<prop key="hibernate.c3p0.min_size">5</prop>
<prop key="hibernate.c3p0.max_size">50</prop>
<prop key="hibernate.c3p0.timeout">300</prop>
<prop key="hibernate.c3p0.max_statements">50</prop>
<prop key="hibernate.c3p0.idle_test_period">3000</prop>
Run Code Online (Sandbox Code Playgroud)
当我写一些数据时,我使用这样的代码
getHibernateTemplate().execute(new HibernateCallback<Void>() {
@Override
public Void doInHibernate(Session session) throws HibernateException, SQLException {
for (Data data : datas) {
session.persist(data);
}
session.flush();
return null;
}
});
Run Code Online (Sandbox Code Playgroud)
但我有一个例外
引起:com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:数据源拒绝建立连接,来自服务器的消息:"连接太多"
我使用netstat -an | grep 3306并看到很多连接.有什么问题,您怎么看?
处理这段代码的更好方法是什么
我有一个如下所示的方法,它将接受一个参数i String并返回一个int值
下面的代码工作正常.
public static int getLoggerLevel(String level)
{
int loglevel = 3;
if (level.equals("INFO")) {
loglevel = 3;
}
else if (level.equals("ERROR")) {
loglevel = 4;
} else if (level.equals("FATAL")) {
loglevel = 5;
}
return loglevel;
}
Run Code Online (Sandbox Code Playgroud)
我想把Key Values放在Map中,并根据String检索它,但是不想创建一个Map我猜哪个会占用内存
AEM 6.0 SP1和搜索组件存在轻微问题.如果寻找一个法语单词一样"Français" 的"ç"得到弄糟
查询字符串就像?q=Français
在JSP端一样,request.getCharacterEncoding()返回ISO-8859-1而不是我们需要的UTF-8.
我知道在tomcat下你可以改变URIEncoding连接器级别.
但是对于直接由它自己运行的AEM/CQ实例,没有这样的事情.有人想出来了吗?
java ×6
aem ×3
swing ×2
apache-felix ×1
capybara ×1
connection ×1
css ×1
cucumber ×1
hibernate ×1
html ×1
itemlistener ×1
jcombobox ×1
mysql ×1
osgi ×1
ruby ×1
site-prism ×1
spring ×1