使用scanf()获取输入时,在点击class MessageFile{
public static final String fileName="Main.html"
@AutoWired
AppConifg appconfig;
private static final Map<String, File> filesMap = new HashMap<>();
public boolean writeToFile(String fileContent) throws Exception{
String path = appConfig.getNewsPath() + File.separator + fileName; // getNewsPath is non-static method
final File alertFile;
synchronized(filesMap) {
if (filesMap.containsKey(path)) {
alertFile = filesMap.get(path);
}
else {
alertFile = new File(path);
filesMap.put(path, alertFile);
}
}
FileOutputStream out = null;
synchronized (alertFile) {
if (!alertFile.exists()) {
alertFile.createNewFile();
}
try {
out = new FileOutputStream(alertFile, false);
out.write(fileContent.getBytes());
out.flush();
} finally {
if (out != null) {
out.close();
}
}
}
return true;
}
}
后提示切换到新行。在接受输入后,我怎样才能保持同一条线?
答案 0 :(得分:0)
如果您可以使用escape sequences(非便携式):
class Job < ApplicationRecord
has_and_belongs_to_many :job_type
end
class JobType < ApplicationRecord
has_and_belongs_to_many :job
end
答案 1 :(得分:0)
解析您的输入,当您找到&#39; \ n&#39;将其替换为&#39; \ 0&#39;