java - Reading String from the File -


what doing wrong in code reading string. suppose following string passed layout:

string m = "..z\n"+           "...\n"+           "...\n"+           "...\n"+           "z..\n"+           ""; 

my method should return same result it's not returning me anything, not pring anything. please not suggest using stringbuilder or smth similar. can smb please me out this?

public static shape makeshape(string layout,char displaychar)   {       shape result;       int height = 0;       int width = 0;       scanner data = new scanner(layout);       char[][] temp;       while(data.hasnextline())       {           string line = data.nextline();           height = line.length();           width++;       }       temp = new char[height][width];        scanner data2 = new scanner(layout);       while(data.hasnextline())       {           string line2 = data.nextline();           if(line2.charat(0) == '.' && line2.charat(width) == '.')               throw new fititexception("empty borders!");              else {                  (int r = 0; r < height; r++)                     (int c = 0; c < width; c++) {                         //system.out.println(line2.charat(c));                          if (temp[r][c] == '.') {                             temp[r][c] = displaychar;                         }                         system.out.println(line2.charat(temp[r][c]));                      }             }       }       result = new createshape(height, width, displaychar);       return result;   } 

hint: carefully @ these 2 lines:

  scanner data2 = new scanner(layout);   while(data.hasnextline()) 

do see wrong ... ... variable ... names ... ?


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -