当前位置: 首页>>代码示例>>Java>>正文


Java Reader.close方法代码示例

本文整理汇总了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();
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:RumenToSLSConverter.java

示例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) {
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Basic.java

示例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();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:Util.java

示例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 &amp, &quot 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);
      }
    }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:37,代码来源:TestRepositioningInfo.java

示例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();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:CommandLine.java

示例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();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:CommandLine.java

示例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();
  }
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:31,代码来源:Utils.java

示例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();
    }
}
 
开发者ID:Jiabaokang,项目名称:JBKWeather,代码行数:17,代码来源:DiskLruCache.java

示例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();
	}
}
 
开发者ID:Spencer231,项目名称:GifImageLoader,代码行数:14,代码来源:Util.java

示例10: load

import java.io.Reader; //导入方法依赖的package包/类
@Override
public synchronized void load(Reader reader) throws IOException
{
	try
	{
		super.load(reader);
	}
	finally
	{
		reader.close();
	}
}
 
开发者ID:L2jBrasil,项目名称:L2jBrasil,代码行数:13,代码来源:L2Properties.java

示例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();
  }
}
 
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:16,代码来源:OpenSSHConfig.java

示例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);
}
 
开发者ID:Caratacus,项目名称:mybatis-plus-mini,代码行数:16,代码来源:PaginationInterceptorTest.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:PropertiesEditorSupport.java

示例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 ();
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:CommonPackageDeploymentContext.java

示例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();
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:31,代码来源:NetworkingModule.java


注:本文中的java.io.Reader.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。