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


Java CharArrayReader.close方法代码示例

本文整理汇总了Java中java.io.CharArrayReader.close方法的典型用法代码示例。如果您正苦于以下问题:Java CharArrayReader.close方法的具体用法?Java CharArrayReader.close怎么用?Java CharArrayReader.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.CharArrayReader的用法示例。


在下文中一共展示了CharArrayReader.close方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_markI

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * java.io.CharArrayReader#mark(int)
 */
public void test_markI() throws IOException {
    cr = new CharArrayReader(hw);
    cr.skip(5L);
    cr.mark(100);
    cr.read();
    cr.reset();
    assertEquals("Test 1: Failed to mark correct position;",
            'W', cr.read());

    cr.close();
    try {
        cr.mark(100);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:21,代码来源:OldCharArrayReaderTest.java

示例2: test_reset

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * java.io.CharArrayReader#reset()
 */
public void test_reset() throws IOException {
    cr = new CharArrayReader(hw);
    cr.skip(5L);
    cr.mark(100);
    cr.read();
    cr.reset();
    assertEquals("Test 1: Reset failed to return to marker position.",
            'W', cr.read());

    cr.close();
    try {
        cr.reset();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:21,代码来源:OldCharArrayReaderTest.java

示例3: test_skipJ

import java.io.CharArrayReader; //导入方法依赖的package包/类
public void test_skipJ() throws IOException {
    long skipped = 0;
    cr = new CharArrayReader(hw);
    skipped = cr.skip(5L);
    assertEquals("Test 1: Failed to skip correct number of chars;",
            5L, skipped);
    assertEquals("Test 2: Skip skipped wrong chars;",
            'W', cr.read());

    cr.close();
    try {
        cr.skip(1);
        fail("Test 3: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:18,代码来源:OldCharArrayReaderTest.java

示例4: close

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * @tests java.io.CharArrayReader#close()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "Verifies close() method.",
    method = "close",
    args = {}
)
public void test_close() {
    cr = new CharArrayReader(hw);
    cr.close();
    try {
        cr.read();
        fail("Failed to throw exception on read from closed stream");
    } catch (IOException e) {
        // Expected.
    }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:21,代码来源:CharArrayReaderTest.java

示例5: test_markI

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * @tests java.io.CharArrayReader#mark(int)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "mark",
    args = {int.class}
)
public void test_markI() throws IOException {
    // Test for method void java.io.CharArrayReader.mark(int)
    cr = new CharArrayReader(hw);
    cr.skip(5L);
    cr.mark(100);
    cr.read();
    cr.reset();
    assertEquals("Test 1: Failed to mark correct position;",
            'W', cr.read());

    cr.close();
    try {
        cr.mark(100);
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:CharArrayReaderTest.java

示例6: test_reset

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * @tests java.io.CharArrayReader#reset()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "reset",
    args = {}
)
public void test_reset() throws IOException {
    cr = new CharArrayReader(hw);
    cr.skip(5L);
    cr.mark(100);
    cr.read();
    cr.reset();
    assertEquals("Test 1: Reset failed to return to marker position.",
            'W', cr.read());

    cr.close();
    try {
        cr.reset();
        fail("Test 2: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:CharArrayReaderTest.java

示例7: test_skipJ

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * @tests java.io.CharArrayReader#skip(long)
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    method = "skip",
    args = {long.class}
)
public void test_skipJ() throws IOException {
    long skipped = 0;
    cr = new CharArrayReader(hw);
    skipped = cr.skip(5L);
    assertEquals("Test 1: Failed to skip correct number of chars;",
            5L, skipped);
    assertEquals("Test 2: Skip skipped wrong chars;",
            'W', cr.read());

    cr.close();
    try {
        cr.skip(1);
        fail("Test 3: IOException expected.");
    } catch (IOException e) {
        // Expected.
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:CharArrayReaderTest.java

示例8: test_close

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * java.io.CharArrayReader#close()
 */
public void test_close() {
    cr = new CharArrayReader(hw);
    cr.close();
    try {
        cr.read();
        fail("Failed to throw exception on read from closed stream");
    } catch (IOException e) {
        // Expected.
    }

}
 
开发者ID:Sellegit,项目名称:j2objc,代码行数:15,代码来源:OldCharArrayReaderTest.java

示例9: test_close

import java.io.CharArrayReader; //导入方法依赖的package包/类
/**
 * @tests java.io.CharArrayReader#close()
 */
public void test_close() {
    cr = new CharArrayReader(hw);
    cr.close();
    try {
        cr.read();
        fail("Failed to throw exception on read from closed stream");
    } catch (IOException e) {
        // Expected
    }

    // No-op
    cr.close();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:CharArrayReaderTest.java

示例10: parseTokens

import java.io.CharArrayReader; //导入方法依赖的package包/类
private ArrayList<String> parseTokens(String quoteLine) throws IOException {
    if (quoteLine == null) {
        throw new IllegalArgumentException("parseTokens cannot accept null parameter");
    }
    ArrayList<String> tokenList = new ArrayList<String>();
    CharArrayReader charReader = new CharArrayReader(quoteLine.toCharArray());
    int c = charReader.read();
    if (c == -1) {
        //empty quote line??
        return tokenList;
    }
    StringBuffer sb;
    while (c != -1) {
        sb = new StringBuffer();
        if (c == ',') {
            c = charReader.read();
            if (c == ',' || c == -1) {
                //empty token
                sb.append("N/A");
                tokenList.add(sb.toString());
                c = charReader.read();
            }
            continue;
        }
        if (c == '"') {
            c = charReader.read();
            if (c == '"') {
                // empty quoted string
                tokenList.add("N/A");
                c = charReader.read();
                continue;
            }
            while (c != '"') { // take anything inside quotes as single field
                if (c == -1) {
                    throw new IOException("Missing end quote!");
                }
                sb.append((char) c);
                c = charReader.read();
            }
            tokenList.add(sb.toString());
            c = charReader.read();
            continue;
        }
        while (c != ',' && c != -1) { // take anything up to a comma or end
            sb.append((char) c);
            c = charReader.read();
        }
        tokenList.add(sb.toString());
    }
    charReader.close();
    return tokenList;
}
 
开发者ID:bigd722,项目名称:YahooFinanceAPI,代码行数:53,代码来源:YFApi.java


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