Jump to content
  • 0

Readline() Java Problem Doesen't Read The Whole Line.


Question

Posted
			url = new URL(Config.WEB_LINK);
			is = url.openStream(); // throws an IOException
			br = new BufferedReader(new InputStreamReader(is));
			int count = 0;
			while ((line = br.readLine()) != null)
			{
				if (count == 0)
				{
					comanda = line;
				}
				count++;
			}
			System.out.println("DEBUG: Webcheck:" + comanda);

The file is a simple .txt file containing "Still doesen't work how it should."

 

First output: DEBUG: Webcheck:announce Still doesen't work how it s

Second output: DEBUG: Webcheck:announce Still doesen't work how it should.

 

I've made a thread to check every 60 seconds and the first time doesen't read the whole line, but the second time it read it.

Any idea why?

Recommended Posts

  • 0
Posted

U could try with

 

 

try
{
URLConnection conn = new URL(Config.WEB_LINK).openConnection();
conn.addRequestProperty("User-Agent", "Mozilla/4.76");
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
         BufferedReader in = new BufferedReader(isr);
String inputLine;
 
while ((inputLine = in.readLine()) != null)
{
System.out.println("DEBUG: Webcheck:" + inputLine);
}
in.close();
}
catch (Exception e)
{
System.out.println("Something went wrong:" + e);
}

Btw could u post the link of that html ;D

  • 0
Posted (edited)

U could try with

try
{
URLConnection conn = new URL(Config.WEB_LINK).openConnection();
conn.addRequestProperty("User-Agent", "Mozilla/4.76");
InputStreamReader isr = new InputStreamReader(conn.getInputStream());
         BufferedReader in = new BufferedReader(isr);
String inputLine;
 
while ((inputLine = in.readLine()) != null)
{
System.out.println("DEBUG: Webcheck:" + inputLine);
}
in.close();
}
catch (Exception e)
{
System.out.println("Something went wrong:" + e);
}

Btw could u post the link of that html ;D

 

Is a simple txt file, not even html

Edited by TroubleChick
  • 0
Posted (edited)

Whatever but I was lazy to upload one to my ftp to test xD I will, then... q.q

 

P.S: for me it's warking what I posted

 

P.S 2: What you posted is also working for me, with the try() catch() that's missing...

Edited by ^Wyatt
  • 0
Posted (edited)

Whatever but I was lazy to upload one to my ftp to test xD I will, then... q.q

 

P.S: for me it's warking what I posted

I made a different class in eclipse to see if it's working and both ways it's working, BUT when i go in the gameserver first time doesent read all the line and second time it does. I don't get it.

Could be the format of TXT file or anything?!

 <?
if($_POST['Submit']){
$open = fopen("commands.txt","w+");
$text = $_POST['update'];
fwrite($open, $text);
fclose($open);
echo "File updated.<br />"; 
echo "File:<br />";
$file = file("commands.txt");
foreach($file as $text) {
echo $text."<br />";
}
}else{
$file = file("textfile.txt");
echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
echo "<textarea Name=\"update\" cols=\"30\" rows=\"1\">";
foreach($file as $text) {
echo $text;
} 
echo "</textarea>";
echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
</form>";
}
?> 

This is the PHP script that edit the file.

Edited by TroubleChick
  • 0
Posted (edited)

I don't think that is about file extension... but u can simply test it...

Btw how did u schedule the check, can u post it here? U could test adding some more seconds for the first check.

Edited by ^Wyatt
  • 0
Posted

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new checkIt(), 60000, Config.WEB_INTERVAL * 1000);//

 

Everytime i change something at the commands.txt file sometimes it doesen't work from first time.

 

Weird Example: I test the new class with new text everytime and it reads whole. And if i read whole before the new check comes the check is reading whole too.

  • 0
Posted (edited)

But what has to do the php form with your code? I mean, your code is just checking the file, isn't it?

You could give me the link to see if I get your error too  :rage:

Edited by ^Wyatt
  • 0
Posted (edited)

Yes just checking the file and taking the first line. I don't get it why it loose ends of the line first time.

 

LE: Isn't 60 seconds enough?

 

OUTPUT1: DEBUG: Webcheck:announce i dont fucking get it.asda

OUTPUT2: DEBUG: Webcheck:announce i dont fucking get it.asdas

	public static String getContent()
	{
		String comanda = "";
		
		try
		{
			URLConnection conn = new URL(Config.WEB_LINK).openConnection();
			conn.addRequestProperty("User-Agent", "Mozilla/4.76");
			InputStreamReader isr = new InputStreamReader(conn.getInputStream());
			BufferedReader in = new BufferedReader(isr);
			String inputLine;
			int count = 0;
			
			while ((inputLine = in.readLine()) != null)
			{
				if (count == 0)
				{
					System.out.println("DEBUG: Webcheck:" + inputLine);
					comanda = inputLine;
				}
			}
			in.close();
		}
		catch (Exception e)
		{
			System.out.println("Something went wrong:" + e);
		}
		return comanda;
	}
	
Edited by TroubleChick
  • 0
Posted

Ye it should. Try something, debug all lines, not only the first, to make sure that is not related with <br />, if the first check debugs you the line splitted in 2 lines it will be coz <br />, I guess.

  • 0
Posted (edited)

But the file has only 1 line. I'll try to make it html and at the end of line ill put a </br /> to see if its working.

 

LE: Same thing even if it's HTML extension.

 

Not even this way works:

			StringBuilder responseData = new StringBuilder();
			
			while ((inputLine = in.readLine()) != null)
			{
				responseData.append(inputLine);
			}
			System.out.println(responseData.toString());
			comanda = responseData.toString();
Edited by TroubleChick
  • 0
Posted (edited)

I can't help you at all coz I don't understand how do you test it.

Could you explain me what do you do, to be able to do the same as you and get the same problem? ;(

 

Edit: I'm just trying to schedule checks and works fine... it must be problem of your php thing... maybe the first check is trying to access to the file while php is changing it...

Edited by ^Wyatt
  • 0
Posted (edited)

Ok first of all. Im trying to make a script that read a line from a text file from a website.

 

1.If i add the script in gameserver and put to run in Gameserver.java first time it doesen't read the whole line and only few words from it. The next schedule it's reading the whole line.

 

2. I tried to make the script run by itself without putting in gameserver just compiling a java class and it works everytime. i see the output correctly and seeing the whole line.

 

LE: i edit the .txt file manual not with the php script and it works perfectly. Any idea what could php script have?

Edited by TroubleChick
  • 0
Posted

But when you have the script running from the gameserver, what about the .txt file and the php? Is the php chaning it?

Or when does the php act here?

  • 0
Posted

The php script is only to edit the .txt file as i showed you the script a little bit upper

The php act here to. Php is changing the .txt file.

 

 

In theory: I have a file .txt on a server and a .php. The php script is a textarea that edit the txt file. The java script from server reads what is in txt and do what's saying there. Problem is that is not reading the whole line!

  • 0
Posted (edited)

You don't get what am I asking. I wonder WHEN the php script acts and by who.

The php script must be acting when java is trying to check, otherwise it has no sense.

Edited by ^Wyatt
Guest
This topic is now closed to further replies.


  • Posts

    • ⚔️ WELCOME TO L2EPICFAIL ⚔️ Server developed by gamers, for gamers! ❄️ WINTER SEASON #8 ❄️ OPEN BETA — 15 NOVEMBER 2026 GRAND OPENING — 20 NOVEMBER 2026, 18:30 GMT+0 Website: https://l2epic.fail/ Discord: https://discord.gg/6hwhrkrHBG ━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚔️ SERVER FEATURES & RATES EXP — 10x SP — 9x Adena — 6x Drop — 3x Spoil — 3x Seal Stones — 3x Epic Raid Boss Drop — 1x Regular Raid Boss — EXP 5x / SP 5x / Drop 4x Quest Drop — 1x (selected quests 2–3x) Quest Rewards — 1x (Adena / EXP / SP 3x) ━━━━━━━━━━━━━━━━━━━━━━━━━━ ★ PREMIUM ACCOUNT EXP +20% SP +20% Adena +20% Drop +20% Spoil +20% Quest Rewards +20% Available through voting, Epic Coins or donations. World Chat — 60 messages per day using "&" Buff Book usable outside towns. Premium applies to all characters on the account. ━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ SPECIAL FEATURES Classic Interface Active Anticheat Vote System Daily Missions Attendance Rewards Masterwork Items Brooches & Diamonds Kamaloka Autofarm Epic Auctioneer Epic Market Price Search No Carrier Protection Raid Rank System PvP Events ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🐉 EPIC BOSSES & RESPAWNS All times GMT+0. Spawn windows visible through .epic. QUEEN ANT — LVL 80 Every day except Wednesday and Sunday 18:00–18:30 Maximum C-grade equipment Boosted HP / Drop Chance 49% CORE — LVL 80 Monday and Friday 20:00–20:15 Maximum B-grade equipment Boosted HP / Drop Chance 60% Core Ring: +1 STR, +1 DEX ORFEN — LVL 80 Tuesday, Thursday and Saturday 20:00–20:15 Maximum B-grade equipment Boosted HP / Drop Chance 60% Orfen Earring: +1 WIT, +1 INT ZAKEN — LVL 80 Monday and Friday 19:00–19:30 Maximum A-grade equipment Automatic PvP Zone BAIUM Every Sunday 18:00–19:00 Automatic PvP Zone / Regular HP FRINTEZZA Tuesday and Thursday 19:00–20:00 Minimum 2 parties / Maximum 5 parties Minimum character level 74 Automatic PvP Zone ANTHARAS Every two weeks on Saturday 19:00–19:30 Automatic PvP Zone VALAKAS Every two weeks on Saturday 19:00–19:30 Automatic PvP Zone Antharas and Valakas spawn on alternating weeks. Epic Bosses drop Epic Medals equal to their level × 10. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏆 RAID RANK Clans earn Raid Rank points by killing Raid Bosses level 30+. Raid Bosses level 75+ award 150 points. Rankings reset every Monday morning. Weekly Rewards: 1st Place — 50 RRR Coins 2nd Place — 40 RRR Coins 3rd Place — 30 RRR Coins 4th Place — 20 RRR Coins 5th Place — 13 RRR Coins RRR Coins can be exchanged for Epic Jewelry. ━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚒️ ENCHANT SYSTEM Safe Enchant — +3 Maximum Enchant — +16 Regular Enchant Chance — 60% Blessed Enchant Chance — 66% Enchant chances progressively decrease after +10. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 💎 BROOCHES & DIAMONDS Maximum Level — +10 Brooch Compound Chance — 25% Diamond Compound Chance — 35% Requires two items of the same type and level. On failure, one item remains in inventory. Disabled during Olympiad. ━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ MASTERWORK ITEMS Masterwork Crafting Chance — 2% A-grade — Armors & Jewelry S-grade — Weapons, Armors & Jewelry ━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚔️ REGULAR RAID BOSSES All regular Raid Bosses have boosted HP. Slightly increased M.Def to give fighters an advantage. Respawn — 24–30 hours Epic Medal Drops — Equal to Raid Boss level Raid Boss status can be checked on the map. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏅 OLYMPIAD Weekly Period Thursday–Saturday, 16:00–22:00 GMT+0 Maximum Equipment Enchant — +7 (progressive) Minimum Non-Class Participants — 5 Minimum Class-Based Participants — 10 ━━━━━━━━━━━━━━━━━━━━━━━━━━ 📜 CLASS TRANSFER 1st Class — 50k Adena 2nd Class — 500k Adena 3rd Class — 25kk Adena + 700 Halisha Marks Halisha Marks are tradeable and drop in Shrine of Loyalty. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 👑 NOBLESSE QUEST Retail-style Noblesse Quest with boosted quest drops. Alternative Method — No Barakiel Kill Required Collect 100 Noble Ants Feeler from Wailing of Splendor in Valley of Saints. Drop Chance — 4% Barakiel Respawn — 10–14 hours Barakiel's Chest provides 10 Noble Ants Feeler when the relevant quest is active. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 📖 SUBCLASS QUEST Minimum Main Class Level — 75 Start the Reorin Quest in Giran. Obtain the required item from Cabrio's Chest first. Collect items from Hallate, Kernon and Golkonda. Return to Reorin and complete the remaining quest requirements. Maximum Subclasses — 5 Cabrio Respawn — 6–8 hours Tower of Insolence Raid Bosses — 8–10 hours ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔮 SKILLS & AUGMENTS Mass Sweep — All Bounty Hunters level 40+ Block Buff — All characters, toggle Escape — 20 seconds, no Scroll of Escape required Automatic Skill Learning Skill Loss After 16 Levels of Delevel Maximum Buffs — 24 + 4 with books Augmentation Skill Chances: Normal Life Stone — 4% Mid-grade Life Stone — 5% High-grade Life Stone — 7% Top-grade Life Stone — 6% Fast Augmentation by double-clicking Life Stones. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🛒 GM SHOP Weapons, Armors and Jewelry — Up to C-grade Soulshots / Spiritshots — Up to C-grade Mana Potions — 500 MP / 5 seconds ━━━━━━━━━━━━━━━━━━━━━━━━━━ ✨ NPC BUFFER All Buffs, Songs and Dances Third Class Buffs and Resists Buff Duration — 1 Hour Buff Book available to every character. ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🌍 GLOBAL GATEKEEPER All Towns Catacombs and Necropolises Tower of Insolence — Floors 3 / 5 / 7 / 10 ━━━━━━━━━━━━━━━━━━━━━━━━━━ 🛡️ CLANS & PVP Maximum Main Clan Members — 80 Maximum Alliance Clans — 3 Clan Leave / Dismiss Penalty — 12 Hours Epic PvP Zone Limit — 4 CPs / 36 Players Clan skills apply to all members without requiring titles. ━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚙️ AUTOFARM Available to Everyone After the First Week Maximum 1 Active Window per HWID Maximum 1 Hour at a Time Requires Autofarm Tickets purchased with Epic Coins and Adena. Activate using .autofarm Disabled While PvP Flagged Third-Party Bot Software Is Prohibited ━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 ADDITIONAL FEATURES Maximum 3 Windows per HWID Only 1 Window Allowed in PvP Zones Teleport Protection — 20 Seconds Weight Limit — 10x Stackable Enchant Scrolls and Life Stones Blue Champions — 5x HP Minimum Trade Level — 40 Minimum Chat Level — 20 Arrows and Spellbook Drops Disabled Blacksmith of Mammon and Merchant of Mammon in Towns Alt+Click Buff Removal 19-Level Party EXP Difference No Carrier Disconnect Protection Payback System ━━━━━━━━━━━━━━━━━━━━━━━━━━
    • They're just jealous because I'm better at prompting than all of them combined. There's all working on L2jPromptius and can't even manage to open a single private server with it in like 10 years, and now they're nervous because I'm sharing tools they've been gatekeeping from the community so they can't profit anymore. Truly shameless behavior from them  They're losing business opportunities with every free share, they literally live from the game, just a bunch of unemployed dudes 
    • I don't understand the hate at all? Why are people getting mad at 911reg for sharing an already free tool but improved? Right now the competition is not in dev ability but in creativity and vision. 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..