Class CSVParser
来源:互联网 发布:英文小说 知乎 编辑:程序博客网 时间:2024/06/04 20:12
原文地址:http://ostermiller.org/utils/javadoc/CSVParser.html
Each line is one entry or record and the fields in a record are separated by commas。每一行是一个整体或者是一条记录,被逗号分隔开
Commas may be preceded or followed by arbitrary space and/or tab characters which are ignored.逗号前后的空格是被忽视的
Commas may be preceded or followed by arbitrary space and/or tab characters which are ignored.如果一条记录不止一行,那么所有的行都是被引号括起来
When the field is in quotes, any quote literals must be escaped by \" Backslash literals must be escaped by \\. Otherwise a backslash and the character following will be treated as the following character, IE. "\n" is equivalent to "n". Other escape sequences may be set using the setEscapes() method.里面一些特殊字符是需要被转义的
Text that comes after quotes that have been closed but come before the next comma will be ignored.在引号结束,下一个引号开始之前,中间的内容都是被忽视的。
Empty fields are returned as as String of length zero: "".
Blank lines are always ignored. Other lines will be ignored if they start with a comment character as set by the setCommentStart() method.
An example of how CSVParser might be used:
CSVParser shredder = new CSVParser(System.in); shredder.setCommentStart("#;!"); shredder.setEscapes("nrtf", "\n\r\t\f"); String t; while ((t = shredder.nextValue()) != null){ System.out.println("" + shredder.lastLineNumber() + " " + t); }
构造函数:
CSVParser(InputStream in)
Create a parser to parse comma separated values from an InputStream.
CSVParser(InputStream in, char delimiter)
Create a parser to parse delimited values from an InputStream.
CSVParser(InputStream in, char delimiter, String escapes, String replacements, String commentDelims)
Create a parser to parse delimited values from an InputStream.
CSVParser(InputStream in,String escapes, String replacements, String commentDelims)
Create a parser to parse comma separated values from an InputStream.
CSVParser(Reader in)
Create a parser to parse comma separated values from a Reader.
CSVParser(Reader in, char delimiter)
Create a parser to parse delimited values from a Reader.
CSVParser(Reader in, char delimiter, String escapes, String replacements, String commentDelims)
Create a parser to parse delimited values from a Reader.
CSVParser(Reader in,String escapes, String replacements, String commentDelims)
Create a parser to parse comma separated values from a Reader.
主要方法:
void
changeDelimiter(char newDelim)
Change this parser so that it uses a new delimiter.
void
changeQuote(char newQuote)
Change this parser so that it uses a new character for quoting.
void
close()
Close any stream upon which this parser is based.
String[][]
getAllValues()
Get all the values from the file.
int
getLastLineNumber()
Get the number of the line from which the last value was retrieved.
String[]
getLine()
Get all the values from a line.
int
lastLineNumber()
Get the line number that the last token came from.
String
nextValue()
get the next value.
static String[][]
parse(Reader in)
Parse the delimited data from a stream.
static String[][]
parse(Reader in, char delimiter)
Parse the comma delimited data from a stream.
static String[][]
parse(Reader in, char delimiter, String escapes, String replacements, String commentDelims)
Parse the delimited data from a stream.
static String[][]
parse(Reader in,String escapes, String replacements, String commentDelims)
Parse the comma delimited data from a stream.
static String[][]
parse(String s)
Parse the comma delimited data from a string.
static String[][]
parse(String s, char delimiter)
Parse the delimited data from a string.
static String[][]
parse(String s, char delimiter, String escapes, String replacements, String commentDelims)
Parse the delimited data from a string.
static String[][]
parse(String s,String escapes, String replacements, String commentDelims)
Parse the comma delimited data from a string.
void
setCommentStart(String commentDelims)
Set the characters that indicate a comment at the beginning of the line.
void
setEscapes(String escapes,String replacements)
Specify escape sequences and their replacements.
- Class CSVParser
- class
- class
- class
- class
- class
- class
- Class
- Class
- class
- Class
- Class<?>
- class
- Class
- Class<?>
- Class
- @class
- @class
- 异常处理的原则:
- 国内外三个不同领域巨头分享的Redis实战经验及使用场景
- 当打开studio没有android项目时
- win10获得system权限(超级管理员)
- 读《Git 版本控制管理第2版》迷你书 pdf(不全)
- Class CSVParser
- 【Java语言】嵌套For循环性能优化案例
- ionic中文javascript API(2)
- c++ error LNK2019问题
- user32大全
- php面试题汇总二
- 实现网页布局的自适应
- Android Studio 1.2版安装设置图文教程
- iOS开发之Xcode6之后不再自动创建Pch预编译文件