read output of txt file has white spaces

后端 未结 3 1182
囚心锁ツ
囚心锁ツ 2021-01-21 11:40

i got the list of applications from cmd command using /output:D:\\list.txt product get name,version. However when i try to retrieve the list using java the output has white spac

3条回答
  •  后悔当初
    2021-01-21 12:17

    Have you tried the FileReader?

    FileReader fileReader;
    try {
        fileReader = new FileReader( "D:\\list.txt" );
        BufferedReader bufferedReader = new BufferedReader( fileReader ); 
        String line; 
        while( ( line = bufferedReader.readLine() ) != null )
        { 
            System.out.println( line ); 
        }
        fileReader.close();
    } catch ( IOException except ) {
        System.err.println( except.getStackTrace()[0] );
    }
    

    Im not shure where your problem is coming from, but you may take the FileReader for such instructions.

提交回复
热议问题