这是场景一的输入
String in = "<ENTER>title=Java-Samples<ENTER>" +
"<ENTER>author=Emiley J<ENTER>" +
"<ENTER>publisher=java-samples.com<ENTER>" +
"<ENTER>copyright=2007<ENTER>" +
"<ENTER>cool beans<ENTER>";
流程
in=in.substring(in.indexOf("<ENTER>")+7,in.lastIndexOf("<ENTER>"));
String[] mSplitted= in.replaceAll("<ENTER><ENTER>", "<ENTER>").split("<ENTER>");
String mFinal="";
for(int i=0;i<mSplitted.length;i++)
{
System.out.println("values: "+mSplitted[i]);
mFinal= mFinal+ mSplitted[i];
}
System.out.println(mFinal);
输出是
title=Java-Samplesauthor=Emiley Jpublisher=java-samples.comcopyright=2007cool beans
塞纳里奥 2
输入
String in = "What is the output of: <ENTER><ENTER>echo 6 % 4;";
流程
in=in.substring(in.indexOf("<ENTER>")+7,in.lastIndexOf("<ENTER>"));
String[] mSplitted= in.replaceAll("<ENTER><ENTER>", "<ENTER>").split("<ENTER>");
String mFinal="";
for(int i=0;i<mSplitted.length;i++)
{
// System.out.println("values: "+mSplitted[i]);
mFinal= mFinal+ mSplitted[i];
}
System.out.println(mFinal);
无输出
我希望输出在使用时添加一个新行