Because you've declared your br
variable inside the try
block, its scope is limited to that block.
To increase br
's scope, declare it before the try
block.
BufferedReader br = null;
try{
br = new BufferedReader( new FileReader( dataIn ) );
}
You'll have to initialize it to null
so you can be sure that it's always initialized to something (even null
) before it's referenced for the first time.
Future references will need to check if it's null
before using it.