• Post Reply Bookmark Topic Watch Topic
  • New Topic

Output Problem  RSS feed

 
Ekrem Altintas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is executing the while-loop once and I can not see result of this statement: System.out.println(satir);



import java.io.*;
import java.net.*;
import java.lang.*;
import java.sql.*;
import java.util.regex.*;
import java.util.*;

public class Derlemeproblem{

public static void main(String args[]) throws IOException
{
URL local = new URL("http://localhost/phpmyadmin/hey.html");
URLConnection baglanti = local.openConnection();


BufferedReader oku = new BufferedReader(new InputStreamReader(baglanti.getInputStream()));


try
{

String satir;
int u,boy;
char[] kelime = new char[2500];
boolean kucuk=false;
u=0;

while ((satir = oku.readLine()) != null)
{

u=satir.length();

boy=0;

if(u!=0&u!=-1)
{
while(boy<u)
{
kar=satir.charAt(boy);

if(kar=='<')
{
kucuk=true;

}

else if(kar=='>')
{
kucuk=false;

}

if(kucuk==false)
{
if (satir.charAt(boy+1)!='<')
{
kelime[boy]=satir.charAt(boy+1);
System.out.println("YAZ "+kelime[boy]);
}
else
{
kucuk=true;
boy=boy+1;
kelime[boy]=' ';
System.out.println("YAZ "+kelime[boy]);
}

}
boy=boy+1;
}

}
System.out.println(satir);
}

}
catch(Exception e)
{
// System.err.println ("Cannot connect to database server");
}

}
}
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's format that code so it might be understood:
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. You said
The code is executing the while-loop once and I can not see result of this statement: System.out.println(satir);
Well, there are two while-loops in that code. But if you do not see the result of System.out.println(satir) then there are a few possibilities:

1. When you print it, the variable satir is all blanks, or it has zero length.

2. There is no data returned from that input stream, so the outer while-loop is actually executed zero times.

3. The code throws an exception, which you ignore.

I bet on #3, but not a large amount of money. I could be wrong. At least change your catch block to report errors when they occur:
 
Ekrem Altintas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help.I solved the problem.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!