• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Output Problem

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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");
}

}
}
 
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's format that code so it might be understood:
 
Paul Clapham
Sheriff
Posts: 28326
96
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help.I solved the problem.
 
permaculture is a more symbiotic relationship with nature so I can be even lazier. Read tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic