Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int getIndexVar(String path, String main, String var){
- String line;
- int bytesVarIndex = 0;
- int bytesVarIndexMain = 0;
- try {
- BufferedReader br = new BufferedReader(new FileReader(path));
- while (!isNull(line = br.readLine())){
- bytesVarIndex++;
- if ("[".equalsIgnoreCase(String.valueOf(line.charAt(0))) && "]".equalsIgnoreCase(String.valueOf(line.charAt((line.length()) - 1)))){
- if (main.equalsIgnoreCase(line)){
- while(!isNull(line = br.readLine())){
- ++bytesVarIndexMain;
- if(var.equalsIgnoreCase(line.substring(0, line.indexOf("=")))){
- br.close();
- return (bytesVarIndex + bytesVarIndexMain);
- }
- }
- }
- }
- }
- } catch (FileNotFoundException ex) {
- System.out.println(ex.getMessage());
- } catch (IOException ex) {
- System.out.println(ex.getMessage());
- }
- return -1; // (-1 = ERROR!);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement