Java 如何从位置读取文本文件

Java 如何从位置读取文本文件,java,file,jakarta-ee,file-io,Java,File,Jakarta Ee,File Io,我正在尝试开发一个可以读取文件的应用程序。但我不知道如何更改读卡器指针的位置,请提供帮助 for(int i=0; i<tab.length; i++){ char cbuf[] = new char[tab[i]]; try { InputStream ips=new FileInputStream(fichier); InputStreamReader ipsr=new InputStreamReader(ips);

我正在尝试开发一个可以读取文件的应用程序。但我不知道如何更改读卡器指针的位置,请提供帮助

for(int i=0; i<tab.length; i++){

    char cbuf[] = new char[tab[i]];

    try {
        InputStream ips=new FileInputStream(fichier); 
        InputStreamReader ipsr=new InputStreamReader(ips);
        BufferedReader br=new BufferedReader(ipsr);

                    //I need to change the position of the pointer here
        br.read(cbuf, 0, tab[i]);


        tabS[i] = new String(cbuf);
        System.out.println(tabS[i]);

        br.close();
    } catch (Exception e){
        System.out.println(e.toString());
    }
}
for(int i=0;i该命令允许您输入下一个字符。使用循环输入字符

// reads and prints BufferedReader
     int Alength = 10;
     int array[] = new int [Alength];
     int value = 0;
     int index = 0;
     while((value = br.read()) != -1 && index < Alength)
     {
         array[index++] = value;
     }
//读取并打印BufferedReader
int-Alength=10;
int数组[]=新的int[Alength];
int值=0;
int指数=0;
while((value=br.read())!=-1&&index
例如,代码-

int c = -1;
while((c=br.read())!=-1){
     //do whatever you like with ch
     char ch = (char)c;
     ...
     ...
}


不幸的是,没有
long tell()
方法,所以我想知道它是否合适。

你想按顺序读取文件吗?是的,这就是我需要的。tab[I]返回什么?玩这个:((line=br.readLine())!=null)还有{2,2,20,8,20,8,4,3,7,3,3,3,18,139},字符读取为整数?这会跳过一些字符,我只需要移动指针而不跳过characters@Gentuzos好吧,不要只是复制和粘贴它。重点是向您展示使用什么以及它们如何工作的示例。所以不是“给出代码”网站。它是一个学习工具好的,谢谢:))@Daniel但我需要移动它,不要跳跃characters@Gentuzos明白了,看看我改变了什么。应该读入(还没有测试过,可以这样做)
br.skip(1000L);