When a wrote the code below in a midlet the Bad Class Access Flag Alert occurs in Runtime and the programme stops. What is the reason for that? What does Bad Class Access Flags Alert mean? Is anyone can inform me? I am going mad...
public static void testURLConnectionCommunication(int numAttempts) {
System.out.println("Necati");
boolean failed = false;
for (int i=0; i<numAttempts; i++) {
HttpURLConnection conn = null;
System.out.println("2");
InputStream is = null;
System.out.println("3");
URL url;
try {
url = new URL("http://www.google.com");
System.out.println("4");
System.out.println("Connection to " + url + ":");
conn = (HttpURLConnection)url.openConnection();
System.out.println("5");
conn.setAllowUserInteraction(false);
conn.setDoInput(true);
conn.setDoOutput(false);
conn.connect();
is = conn.getInputStream();
byte[] buf = new byte[4096];
int len;
while ((len = is.read(buf)) != -1) {
System.out.print(new
String(buf, 0, len));
}
} catch (IOException e) {
System.out.println("URLConnection
test failed on attempt " + i + ":");
e.printStackTrace();
failed = true;
break;
} finally {
if (is != null) {
try {
is.close();
} catch (IOException e) {
System.out.println("Unable to close input stream: " + e.getMessage());
}
}
if (conn != null) {
conn.disconnect();
}
}
System.out.println();
} if (!failed) System.out.println("URLConnection test passed.");
}