我正在尝试使用缓冲阅读器读取文件,但有时会跳过一行中的第一个字符。这是文件,我正在阅读: http: //files.moonmana.com/forums/Rectangle.h
这是结果,我得到:
LINE: #ifndef RECTANGLE_H
LINE: include "Shape.h"
LINE: lass Rectangle : public Shape {
LINE: rivate:
LINE: double _width;
LINE: std::vector<b2Vec2*>* _vertices;
LINE: ublic:
LINE: Rectangle(std::vector<b2Vec2*>* vertices) { _vertices = vertices;};
LINE: void createVertices();
LINE: bool isMimePoint(b2Vec2);
LINE: double getWidth(){return _width;};
LINE: void setWidth(double width);
LINE: void setHeights(double heights);
LINE: ShapeType getType();
LINE: void moveOn( b2Vec2 ,b2Vec2*);
LINE: virtual b2Vec2* getCenter();
LINE: ;
LINE: endif
这是我的源代码:
String path = file.getPath();
BufferedReader _br;
try {
_br = new BufferedReader(new FileReader(path));
do {
System.out.println("LINE: " + _br.readLine());
lines.add(_br.readLine());
} while (_br.read() != -1);
_br.close();
} catch (Exception e) {
System.out.println("Error reading file: " + e.getMessage());
}