I'm doing the askii 2 problem with java, however after my code is done it just shows "Index 0 out of bounds for length 0". this is my code:`
package alex;
import java.io.FileReader;
import java.util.Scanner;
public class askii {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
FileReader fr=new FileReader("aart.txt");
Scanner sc= new Scanner(fr);
String liness=sc.nextLine();
int lines = Integer.parseInt(liness);
for (int i=0;i<lines;i++) {
String[] num1=sc.nextLine().split(" ");
int[] num={};
for(int j=0;j<num1.length;j++) {
num[j]=Integer.parseInt(num1[j]);
}
for(int j=0;j<num.length;j++) {
if(num[j]<53) {
if(num[j]%2==0) {
int askii =num[j]/2+96;
System.out.print(Character.toString(askii));
}
else {
int askii =(int) Math.ceil(num[j]/2)+64;
System.out.print(Character.toString(askii));
}
}
else {
switch(num[j]){
case 53:
System.out.print(" ");
break;
case 54:
System.out.print(".");
break;
case 55:
System.out.print(":");
break;
case 56:
System.out.print("*");
break;
}
}
System.out.println();
}
}
}
catch(Exception e){
System.out.println(e.getMessage());
}
}
}
the "aart.txt" is below:
8
53 53 54 38 38 37 38 38 54 53 54 38 38 37 38 38 54
54 38 37 37 37 30 30 37 37 54 37 37 30 30 37 37 37 38 54
54 38 37 30 30 30 30 30 30 30 30 30 30 30 30 30 37 38 54
54 38 37 53 17 53 23 30 44 10 53 49 30 42 53 53 37 38 54
53 53 54 38 37 30 30 30 30 30 30 30 30 30 37 38 54
53 53 53 54 38 37 37 30 30 30 30 30 37 37 38 54
53 53 53 53 53 54 38 37 30 30 30 37 38 54
53 53 53 53 53 53 53 53 54 38 54
this should be the actual output However, in the console it only shows "Index 0 out of bounds for length 0".
Is there anyway to solve this ?
Thanks!