file io - Java 1.4.2 - Class Variables -


i have simple program in progress needs declaration lines

read = new bufferedreader(new filereader("marks.txt"));

and

line = read.readline();

to class variables. how this?

here code wrote far.

import java.io.*; import java.math.*;  public class writekong {     public static string line;     public static bufferedreader read; public static printwriter write;      public static void main(string[] args) throws ioexception     {                    read = new bufferedreader(new filereader("marks.txt"));             line = read.readline();          while(line != null)         {             system.out.println(line);             read.readline();         }     }      public static void sort()     {     // function does:     //  > check fourth digit in line     //  > if there no fourth digit store mark     //  > if mark less 50 write "fail.txt"     //  > if mark 50 or greater write "pass.txt"       }  } 

edit: want these variables declared class variable. don't want go through pain of redefining same variables in of methods use.

they class variables in code. code satisfies requirements given.

if you're confused why loop not read lines file it's because never assign newly read line to line.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -