Buggy code:
Date logdate = new Date ( ) ; String dateoflog ; dateoflog = date . format ( logdate ) ; int flag = 1 ; while ( flag == 1 ) { String choice ; String duration ; Scanner choicein = new Scanner ( System . in ) ; Scanner durationin = new Scanner ( System . in ) ; System . out . println ( "What<seq2seq4repair_space>do<seq2seq4repair_space>you<seq2seq4repair_space>want<seq2seq4repair_space>to<seq2seq4repair_space>do?<seq2seq4repair_space>(enter<seq2seq4repair_space>1<seq2seq4repair_space>or<seq2seq4repair_space>2.<seq2seq4repair_space>Enter<seq2seq4repair_space>exit<seq2seq4repair_space>to<seq2seq4repair_space>exit<seq2seq4repair_space>the<seq2seq4repair_space>program.)" ) ; System . out . println ( "1.Read<seq2seq4repair_space>expense<seq2seq4repair_space>log" ) ; System . out . println ( "2.<seq2seq4repair_space>Input<seq2seq4repair_space>expense" ) ; choice = choicein . nextLine ( ) ; if ( choice . equals ( "1" ) ) { String file_name ; Scanner userinput = new Scanner ( System . in ) ; System . out . print ( "Please<seq2seq4repair_space>enter<seq2seq4repair_space>file<seq2seq4repair_space>to<seq2seq4repair_space>open:<seq2seq4repair_space>" ) ; file_name = userinput . nextLine ( ) ; System . out . println ( "Please<seq2seq4repair_space>choose<seq2seq4repair_space>range<seq2seq4repair_space>of<seq2seq4repair_space>expense<seq2seq4repair_space>log<seq2seq4repair_space>data<seq2seq4repair_space>to<seq2seq4repair_space>display<seq2seq4repair_space>(enter<seq2seq4repair_space>1,<seq2seq4repair_space>2,<seq2seq4repair_space>3,<seq2seq4repair_space>or<seq2seq4repair_space>4)" ) ; System . out . println ( "1.<seq2seq4repair_space>Month" ) ; System . out . println ( "2.<seq2seq4repair_space>Week" ) ; System . out . println ( "3.<seq2seq4repair_space>Day" ) ; System . out . println ( "4.<seq2seq4repair_space>All" ) ; duration = durationin . nextLine ( ) ; try { ReadFile file = new ReadFile ( file_name ) ; String [ ] aryLines = file . OpenFile ( ) ; String numberholder = "" ; String temp = "" ; int sumofexpense = 0 ; int i ; for ( i = 0 ; i < ( aryLines . length ) ; i ++ ) { temp = aryLines [ i ] ; if ( duration . equals ( "1" ) ) { for ( int x = 0 ; x < ( temp . length ( ) ) ; x ++ ) { if ( ( temp . charAt ( x ) ) == '\t' ) { if ( temp . contains ( dateoflog . substring ( 0 , 7 ) ) ) { System . out . println ( aryLines [ i ] ) ; for ( int j = 0 ; j < x ; j ++ ) { numberholder += temp . charAt ( j ) ; } sumofexpense += Integer . parseInt ( numberholder ) ; numberholder = "" ; } else { } } } } if ( duration . equals ( "2" ) ) { for ( int x = 0 ; x < ( temp . length ( ) ) ; x ++ ) { if ( ( temp . charAt ( x ) ) == '\t' ) { if ( ( ( Integer . parseInt ( temp . substring ( ( x + 9 ) , ( x + 11 ) ) ) ) >= ( ( Integer . parseInt ( dateoflog . substring ( 8 , 10 ) ) ) - 3 ) ) && ( ( Integer . parseInt ( temp . substring ( ( x + 9 ) , ( x + 11 ) ) ) ) <= ( ( Integer . parseInt ( dateoflog . substring ( 8 , 10 ) ) ) + 3 ) ) ) { System . out . println ( aryLines [ i ] ) ; for ( int j = 0 ; j < x ; j ++ ) { numberholder += temp . charAt ( j ) ; } sumofexpense += Integer . parseInt ( numberholder ) ; numberholder = "" ; } else { } } } } if ( duration . equals ( "3" ) ) { for ( int x = 0 ; x < ( temp . length ( ) ) ; x ++ ) { if ( ( temp . charAt ( x ) ) == '\t' ) { if ( temp . contains ( dateoflog . substring ( 0 , 10 ) ) ) { System . out . println ( aryLines [ i ] ) ; for ( int j = 0 ; j < x ; j ++ ) { numberholder += temp . charAt ( j ) ; } sumofexpense += Integer . parseInt ( numberholder ) ; numberholder = "" ; } else { } } } } if ( duration . equals ( "4" ) ) { System . out . println ( aryLines [ i ] ) ; for ( int x = 0 ; x < ( temp . length ( ) ) ; x ++ ) { if ( ( temp . charAt ( x ) ) == '\t' ) { for ( int j = 0 ; j < x ; j ++ ) { numberholder += temp . charAt ( j ) ; } sumofexpense += Integer . parseInt ( numberholder ) ; numberholder = "" ; } } } } System . out . println ( ( "Total<seq2seq4repair_space>amount<seq2seq4repair_space>spent:<seq2seq4repair_space>" + sumofexpense ) ) ; } catch ( IOException e ) { System . out . println ( e . getMessage ( ) ) ; } } else if ( choice . equals ( "2" ) ) { String file_name ; Scanner userinput = new Scanner ( System . in ) ; System . out . println ( "Please<seq2seq4repair_space>enter<seq2seq4repair_space>file<seq2seq4repair_space>to<seq2seq4repair_space>write<seq2seq4repair_space>to" ) ; file_name = userinput . nextLine ( ) ; writetofile data = new writetofile ( file_name , true ) ; System . out . println ( "Enter<seq2seq4repair_space>value<seq2seq4repair_space>to<seq2seq4repair_space>write<seq2seq4repair_space>to<seq2seq4repair_space>text<seq2seq4repair_space>file." ) ; String logvalue ; <START_BUG> int number = Integer . parseInt ( userinput . nextLine ( ) . replaceAll ( "[^\\d]" , "" ) ) ; <END_BUG> logvalue = String . valueOf ( number ) ; data . writeToFile ( ( ( logvalue + "\t" ) + dateoflog ) ) ; System . out . println ( ( ( "The<seq2seq4repair_space>string:<seq2seq4repair_space>" + logvalue ) + "<seq2seq4repair_space>has<seq2seq4repair_space>been<seq2seq4repair_space>written<seq2seq4repair_space>on<seq2seq4repair_space>the<seq2seq4repair_space>file." ) ) ; } else if ( choice . equals ( "exit" ) ) { System . out . println ( "Program<seq2seq4repair_space>will<seq2seq4repair_space>not<seq2seq4repair_space>exit..." ) ; flag = 0 ; } else { System . out . println ( "Invalid<seq2seq4repair_space>input.<seq2seq4repair_space>Please<seq2seq4repair_space>try<seq2seq4repair_space>again." ) ; } } } }

Fix:
int number = Integer . parseInt ( userinput . nextLine ( ) . replaceAll ( "[^\\d]" , "" ) . replaceAll ( "\\s+" , "" ) ) ;