本文整理匯總了Java中org.springframework.util.FileCopyUtils.copyToString方法的典型用法代碼示例。如果您正苦於以下問題:Java FileCopyUtils.copyToString方法的具體用法?Java FileCopyUtils.copyToString怎麽用?Java FileCopyUtils.copyToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.util.FileCopyUtils
的用法示例。
在下文中一共展示了FileCopyUtils.copyToString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
@Override
public void run(ApplicationArguments args) throws Exception {
if (ShellUtils.hasHelpOption(args)) {
String usageInstructions;
final Reader reader = new InputStreamReader(getInputStream(HelpAwareShellApplicationRunner.class, "/usage.txt"));
try {
usageInstructions = FileCopyUtils.copyToString(new BufferedReader(reader));
usageInstructions.replaceAll("(\\r|\\n)+", System.getProperty("line.separator"));
}
catch (Exception ex) {
throw new IllegalStateException("Cannot read stream", ex);
}
System.out.println(usageInstructions);
}
}
示例2: getScriptAsString
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
@Override
public String getScriptAsString() throws IOException {
synchronized (this.lastModifiedMonitor) {
this.lastModified = retrieveLastModifiedTime();
}
Reader reader = this.resource.getReader();
return FileCopyUtils.copyToString(reader);
}
示例3: read
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
public <T> T read(Class<T> type) throws IOException {
BufferedReader in = new BufferedReader(
new InputStreamReader(this.systemStreams.in()));
long startTime = System.currentTimeMillis();
while (!in.ready()) {
Assert.state(System.currentTimeMillis() - startTime < this.timeout,
"Timeout waiting for input");
}
String content = FileCopyUtils.copyToString(in);
String resolved = this.environment.resolvePlaceholders(content);
return this.objectMapper.readValue(new StringReader(resolved), type);
}
示例4: jsonContent
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
private RequestMatcher jsonContent(Resource expected) {
return (request) -> {
String actualJson = ((MockClientHttpRequest) request).getBodyAsString();
String expectedJson = FileCopyUtils.copyToString(new InputStreamReader(
expected.getInputStream(), Charset.forName("UTF-8")));
assertJson(actualJson, expectedJson);
};
}
示例5: readToString
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
public static String readToString(DataBuffer dataBuffer) {
try {
return FileCopyUtils.copyToString(new InputStreamReader(dataBuffer.asInputStream()));
}
catch (IOException e) {
return e.getMessage();
}
}
示例6: binaryOf
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
private String binaryOf(String name) throws IOException {
String resName = "/contracts/" + name + ".bin";
InputStream stream = getClass().getResourceAsStream(resName);
if (stream == null) throw new FileNotFoundException(resName);
return FileCopyUtils.copyToString(new InputStreamReader(stream));
}
示例7: readInternal
import org.springframework.util.FileCopyUtils; //導入方法依賴的package包/類
@Override
protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException {
Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
return FileCopyUtils.copyToString(new InputStreamReader(inputMessage.getBody(), charset));
}