如何使用Stringutils获取上car



我似乎无法获得stringutilss.capital以实际利用我的整个单词字符串。

我已经尝试了多种方法,但是我最终会得到句子类型的情况。我尝试使用strignutilss.capitalize在我想打印的内容中,但这也不起来。我看不见的东西也对我有帮助。

  File file = 
      new File("C:\Users\mikek\Desktop\name.txt"); 
    BufferedReader abc = new BufferedReader(new FileReader(file));
List<String> data = new ArrayList<String>();
String s;
String t;
while((s=abc.readLine()!=null) {
    data.add(s);
    System.out.println("public static final Block " + s.toUpperCase() + "     = new "
+  StringUtils.capitalize(s).replace("_","") + "("" + s + "", Material.ROCK);");
}
abc.close();
 }

预期:木炭块获得:木炭块

这个??

怎么样
        String s = "camel case word";
        String camelCaseSentence = "";
        String[] words = s.split(" ");
        for(String w:words){
            camelCaseSentence += w.substring(0,1).toUpperCase() + w.substring(1) + " ";
        }
        camelCaseSentence = camelCaseSentence.substring(0, camelCaseSentence.length()-1);
        System.out.println(camelCaseSentence);

克里斯·凯特里克(Chris Katric(帮助我找出了什么:

File file = 
  new File("C:\Users\mikek\Desktop\name.txt"); 
BufferedReader abc = new BufferedReader(new FileReader(file));
List<String> data = new ArrayList<String>();
String s;
while((s=abc.readLine())!=null) {
data.add(s);
String camelCaseSentence = "";
    String[] words = s.split("_");
    for(String w:words){
        camelCaseSentence += w.substring(0,1).toUpperCase() + w.substring(1) + " ";
    }
    camelCaseSentence = camelCaseSentence.substring(0, camelCaseSentence.length()-1);
System.out.println("public static final Block " + s.toUpperCase() + " = new "
+  camelCaseSentence.replace(" ", "") + "("" + s + "", Material.ROCK);");
}
abc.close();
 }

现在我得到了(用于system.out.println的整个部分(:"公共静态最终块charcoal_block =新的charcoalblock(" charcoal_block",材料。就像我想要的一样。

相关内容

  • 没有找到相关文章

最新更新