/**
* Get the top section of the file for preview
- * @param inSize number of lines to extract
+ * @param inNumRows number of lines to extract
+ * @param inMaxWidth max length of Strings (longer ones will be chopped)
* @return String array containing non-blank lines from the file
*/
public String[] getSnippet(int inNumRows, int inMaxWidth)
{
for (int i=0; i<size; i++)
{
- if (result[i].length() > inMaxWidth)
- result[i] = result[i].trim();
- if (result[i].length() > inMaxWidth)
- result[i] = result[i].substring(0, inMaxWidth);
+ if (result[i] == null)
+ result[i] = "";
+ else
+ {
+ if (result[i].length() > inMaxWidth)
+ result[i] = result[i].trim();
+ if (result[i].length() > inMaxWidth)
+ result[i] = result[i].substring(0, inMaxWidth);
+ }
}
}
return result;