本文整理汇总了Java中java.io.Reader.close方法的典型用法代码示例。如果您正苦于以下问题:Java Reader.close方法的具体用法?Java Reader.close怎么用?Java Reader.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.Reader
的用法示例。
在下文中一共展示了Reader.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSLSLoadFile
import java.io.Reader; //导入方法依赖的package包/类
private static void generateSLSLoadFile(String inputFile, String outputFile)
throws IOException {
Reader input = new FileReader(inputFile);
try {
Writer output = new FileWriter(outputFile);
try {
ObjectMapper mapper = new ObjectMapper();
ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter();
Iterator<Map> i = mapper.readValues(
new JsonFactory().createJsonParser(input), Map.class);
while (i.hasNext()) {
Map m = i.next();
output.write(writer.writeValueAsString(createSLSJob(m)) + EOL);
}
} finally {
output.close();
}
} finally {
input.close();
}
}
示例2: copy
import java.io.Reader; //导入方法依赖的package包/类
static void copy(Reader src, Writer dst) throws IOException {
int len;
char[] buf = new char[1024];
try {
while ((len = src.read(buf)) != -1)
dst.write(buf, 0, len);
} finally {
try {
src.close();
} catch (IOException ignored1) {
} finally {
try {
dst.close();
} catch (IOException ignored2) {
}
}
}
}
示例3: readFully
import java.io.Reader; //导入方法依赖的package包/类
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
while (true) {
int count = reader.read(buffer);
if (count == -1) {
break;
}
writer.write(buffer, 0, count);
}
String stringWriter = writer.toString();
return stringWriter;
} finally {
reader.close();
}
}
示例4: testRepositioningInfo
import java.io.Reader; //导入方法依赖的package包/类
/**
* This method tests if Repositinioning Information works.
* It creates a document using an xml file with preserveOriginalContent
* and collectRepositioningInfo options keeping true and which has all
* sorts of special entities like &, " etc. + it contains both
* kind of unix and dos stype new line characters. It then saves the
* document to the temporary location on the disk using
* "save preserving document format" option and then compares the contents of
* both the original and the temporary document to see if they are equal.
* @throws java.lang.Exception
*/
public void testRepositioningInfo() throws Exception {
// here we need to save the document to the file
String encoding = ((DocumentImpl)doc).getEncoding();
File outputFile = File.createTempFile("test-inline1","xml");
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(outputFile),encoding);
writer.write(doc.toXml(null, true));
writer.flush();
writer.close();
Reader readerForSource = new BomStrippingInputStreamReader(new URL(testFile).openStream(),encoding);
Reader readerForDesti = new BomStrippingInputStreamReader(new FileInputStream(outputFile),encoding);
while(true) {
int input1 = readerForSource.read();
int input2 = readerForDesti.read();
if(input1 < 0 || input2 < 0) {
assertTrue(input1 < 0 && input2 < 0);
readerForSource.close();
readerForDesti.close();
outputFile.delete();
return;
} else {
assertEquals(input1,input2);
}
}
}
示例5: loadCmdFile
import java.io.Reader; //导入方法依赖的package包/类
private static void loadCmdFile(String name, List args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != st.TT_EOF) {
args.add(st.sval);
}
r.close();
}
示例6: loadCmdFile
import java.io.Reader; //导入方法依赖的package包/类
private static void loadCmdFile(String name, List<String> args)
throws IOException
{
Reader r = new BufferedReader(new FileReader(name));
StreamTokenizer st = new StreamTokenizer(r);
st.resetSyntax();
st.wordChars(' ', 255);
st.whitespaceChars(0, ' ');
st.commentChar('#');
st.quoteChar('"');
st.quoteChar('\'');
while (st.nextToken() != StreamTokenizer.TT_EOF) {
args.add(st.sval);
}
r.close();
}
示例7: readFile
import java.io.Reader; //导入方法依赖的package包/类
/**
*
* @param reader リーダー
*
* @return ファイルの内容
*
* <p>readFile - Utils</p>
*
* <p>fileで指定したファイルを読み込みます。</p>
*
* Jupiter by Jupiter Development Team
*
*/
public static String readFile(Reader reader) throws IOException {
BufferedReader br = new BufferedReader(reader);
String temp;
StringBuilder stringBuilder = new StringBuilder();
temp = br.readLine();
while (temp != null) {
if (stringBuilder.length() != 0) {
stringBuilder.append("\n");
}
stringBuilder.append(temp);
temp = br.readLine();
}
br.close();
reader.close();
return stringBuilder.toString();
}
示例8: readFully
import java.io.Reader; //导入方法依赖的package包/类
/**
* Returns the remainder of 'reader' as a string, closing it when done.
*/
public static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
示例9: readFully
import java.io.Reader; //导入方法依赖的package包/类
static String readFully(Reader reader) throws IOException {
try {
StringWriter writer = new StringWriter();
char[] buffer = new char[1024];
int count;
while ((count = reader.read(buffer)) != -1) {
writer.write(buffer, 0, count);
}
return writer.toString();
} finally {
reader.close();
}
}
示例10: load
import java.io.Reader; //导入方法依赖的package包/类
@Override
public synchronized void load(Reader reader) throws IOException
{
try
{
super.load(reader);
}
finally
{
reader.close();
}
}
示例11: parseFile
import java.io.Reader; //导入方法依赖的package包/类
/**
* Parses the given file, and returns an instance of ConfigRepository.
*
* @param file OpenSSH's config file
* @return an instanceof OpenSSHConfig
*/
public static OpenSSHConfig parseFile(String file) throws IOException {
Reader r = new FileReader(Util.checkTilde(file));
try {
return new OpenSSHConfig(r);
}
finally {
r.close();
}
}
示例12: setUp
import java.io.Reader; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
SqlSession session = sqlSessionTemplate.getSqlSessionFactory().openSession();
Connection conn = session.getConnection();
Reader reader = Resources.getResourceAsReader("com/baomidou/mybatisplus/test/plugins/paginationInterceptor/CreateDB.sql");
ScriptRunner runner = new ScriptRunner(conn);
runner.setLogWriter(null);
runner.runScript(reader);
reader.close();
session.close();
// 随机当前页和分页大小
size = RandomUtils.nextInt(1, 50);
current = RandomUtils.nextInt(1, 200 / size);
System.err.println("当前页为:" + current + " 分页大小为" + size);
}
示例13: loadFromStreamToKit
import java.io.Reader; //导入方法依赖的package包/类
/**
* Reads the file from the stream, filter the guarded section
* comments, and mark the sections in the editor. Overrides superclass method.
* @param document the document to read into
* @param inputStream the open stream to read from
* @param editorKit the associated editor kit
* @throws <code>IOException</code> if there was a problem reading the file
* @throws <code>BadLocationException</code> should not normally be thrown
* @see #saveFromKitToStream
*/
@Override
protected void loadFromStreamToKit(StyledDocument document, InputStream inputStream, EditorKit editorKit) throws IOException, BadLocationException {
final Charset c = getCharset();
final Reader reader = new BufferedReader(new InputStreamReader(inputStream, c));
try {
editorKit.read(reader, document, 0);
} finally {
reader.close();
}
}
示例14: addPreInstallationScript
import java.io.Reader; //导入方法依赖的package包/类
@Override
public void addPreInstallationScript ( final Reader reader ) throws IOException
{
try
{
CharStreams.copy ( reader, this.preInstallation );
}
finally
{
reader.close ();
}
}
示例15: readWithProgress
import java.io.Reader; //导入方法依赖的package包/类
private void readWithProgress(
RCTDeviceEventEmitter eventEmitter,
int requestId,
ResponseBody responseBody) throws IOException {
long totalBytesRead = -1;
long contentLength = -1;
try {
ProgressResponseBody progressResponseBody = (ProgressResponseBody) responseBody;
totalBytesRead = progressResponseBody.totalBytesRead();
contentLength = progressResponseBody.contentLength();
} catch (ClassCastException e) {
// Ignore
}
Reader reader = responseBody.charStream();
try {
char[] buffer = new char[MAX_CHUNK_SIZE_BETWEEN_FLUSHES];
int read;
while ((read = reader.read(buffer)) != -1) {
ResponseUtil.onIncrementalDataReceived(
eventEmitter,
requestId,
new String(buffer, 0, read),
totalBytesRead,
contentLength);
}
} finally {
reader.close();
}
}