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

    • FOREVERCAST AUTOMATED FISHING FOR WORLD OF WARCRAFT FOREVER Cast. Relax. Repeat. READY FOR LAUNCH AVAILABLE JUST HOURS BEFORE WOW FOREVER RELEASES 1-HOUR FREE TRIAL — NO PAYMENT REQUIRED   MEET FOREVERCAST Your fishing companion for WoW Forever. ForeverCast is a Windows-based fishing automation application designed to make fishing simpler, smoother, and more convenient. Automatically cast your line, detect bites, interact with the bobber, and repeat — all through an easy-to-use interface. Featuring two fishing methods, customizable controls, randomized behaviors, and session management, ForeverCast gives you control over how you fish. Development is complete, and ForeverCast is being prepared for its official launch alongside WoW Forever.   SEE FOREVERCAST IN ACTION OFFICIAL GAMEPLAY SHOWCASE       TWO FISHING METHODS 01 — NATIVE INTERACT (RECOMMENDED) Audio-based splash detection combined with WoW's native interaction controls. No manual bobber positioning or screen calibration required. 02 — CURSOR SCAN Our original visual fishing method. Detects the fishing bobber on screen and interacts through cursor-based controls. Two methods. One goal. A simpler fishing experience.   AUTOMATION FEATURES AUTOMATED FISHING Cast, detect bites, interact, and repeat automatically. RANDOMIZED TIMING Variable interaction delays and recast cooldowns. RANDOM IDLE PAUSES Optional fishing breaks with automatic resumption. AUTOMATIC BAG CHECKS Optional randomized bag checks between casts. SMOOTH MOUSE MOVEMENTS Optional gradual cursor movements with varied paths and speeds. RANDOM CHARACTER MOVEMENT Optional alternating movements using configurable strafe keys. Each optional behavior can be enabled or disabled independently.   DESIGNED AROUND YOUR PREFERENCES CUSTOMIZABLE CONTROLS Configure fishing keys, interaction methods, audio sensitivity, and timing. SMART SESSION LIMITS Set maximum fishing duration and catch limits. SESSION TRACKING Monitor catches, elapsed time, and saved session progress. QUICK START & STOP Start or stop fishing using the F6 hotkey. SIMPLE WINDOWS INTERFACE Clean dashboard, activity logs, guided setup, and helpful settings. EXTERNAL OPERATION Runs outside World of Warcraft without reading game memory or injecting code.   PRICING & ACCESS FREE TRIAL — €0 60 MINUTES OF ACCESS Experience ForeverCast before purchasing. No payment required. MONTHLY LICENSE — €8.99 30 DAYS OF ACCESS One month of access starting from activation. LIFETIME LICENSE — €39.99 ONE-TIME PURCHASE Permanent access to ForeverCast. No recurring subscription fees.   LAUNCH INFORMATION FOREVERCAST IS READY Core fishing functionality implemented and tested. Both fishing methods available. Automation features integrated. Session management implemented. License activation and free trial system prepared. Standalone Windows application built. OFFICIAL RELEASE PLAN ForeverCast will become available approximately a few hours before the official opening of WoW Forever. This gives players an opportunity to download the application, activate their free trial or license, and configure their preferred fishing settings ahead of launch. The exact download and activation details will be published through our Discord community.   JOIN THE FOREVERCAST COMMUNITY Want to be among the first to try ForeverCast? Join our Discord for release notifications, downloads, license information, support, and future updates. JOIN THE OFFICIAL FOREVERCAST DISCORD Developer Contact: Nythrand     FOREVERCAST A SMARTER WAY TO FISH. READY FOR WOW FOREVER Cast. Relax. Repeat.
    • 911reg MapExtractor — The Community Contributions Update   Another update, gentlemen.   First of all, I'd like to express my sincere gratitude to the wonderful members of this community who have been kind enough to dedicate their valuable time and expertise to helping me improve this project.   The amount of support I've received since releasing this tool has been truly overwhelming. I honestly didn't expect so many experienced developers to volunteer their services completely free of charge.   @Mobius, in particular, was kind enough to point out that my generator lacked pathnode support. Excellent suggestion! I immediately added it with a single ChatGPT prompt, remotely through AnyDesk on my phone. I wasn't even sitting at my computer. It's genuinely inspiring to see someone with three months of dedicated development experience taking time out of his busy schedule to help someone who was lying in bed.   I'd also like to extend my gratitude to Mobius for providing the L2jMobius emulator, which I've been using to test both geodata and pathnode generation. While the emulator itself remains somewhat underdeveloped, it has proven to be an amazing testing environment for my little project. It's wonderful to see developers contributing to the community in so many different ways, even when they aren't the best at it. Thank you for your continued support!   @Galagard deserves special recognition for his outstanding commitment to quality assurance. He generously provided a comprehensive list of issues involving boundaries, heightmaps, WorldZ, water generation, and 256×256 errors, completely unprompted! I was honestly surprised by the amount of effort he put into helping me. I simply forwarded his findings to ChatGPT, saving myself the inconvenience of investigating anything manually. It's rare to find someone so passionate about improving another developer's free software. Thank you for your unpaid service. Your dedication will not be forgotten.   @Bazookarpm, our unofficial UI/UX consultant, also provided some exceptionally detailed feedback regarding the visual appearance of the application. His assessment was so passionate that he even reported experiencing visual cancer after looking at the interface. Naturally, I took his concerns very seriously and redesigned the entire UI. I sincerely hope the new design meets his expectations and that his recovery is progressing well. Thank you for sacrificing your eyesight in the name of open-source software.   Changelog: Completely redesigned interface. Added pathnode generation. Improved geodata generation. Addressed reported issues with boundaries, heightmaps, WorldZ and water. Various fixes and improvements. Tested geodata and pathnodes using the generously provided L2jMobius emulator.   I genuinely cannot express how grateful I am for this level of community involvement.   Some developers have to spend months identifying problems, gathering feedback, and planning new features. Fortunately, I have access to a group of highly motivated individuals who are willing to do all of that for me, entirely voluntarily.   Not only did they identify areas for improvement, but they also took the time to write lengthy, detailed explanations of their findings. All without being asked, without expecting payment, and apparently without requiring any encouragement whatsoever.   This is what a healthy open-source community should look like.   At 911reg, I believe in recognizing the people who make our achievements possible. That's why I would like to officially acknowledge the following contributors:   Mobius — Pathnode Research & Development / Testing Infrastructure Provider Galagard — Quality Assurance & Bug Reporting Bazookarpm — User Interface & Ophthalmological Testing I sincerely hope this collaboration continues. With enough community support, I might eventually be able to release updates without even reading the source code. Or even asking another AI to prompt for me.   To @Mobius and @Galagard, I would also like to wish you both the very best of luck finding employment in this rapidly evolving industry.    Once again, thank you for your continued dedication to the 911reg MapExtractor project. Your contributions are deeply appreciated, and I look forward to receiving further unsolicited assistance.   This is what 911reg stands for. Haters, eat your hearts out. https://github.com/911reg/911reg-MapExtractor/releases/download/v0.8.0/911reg-MapExtractor-0.8.0-win64.zip
    • Version 0.8.5 - Lobby viewing and batch NPC export   Download   I originally wasn’t planning to release this version, as I was working towards 1.0.0. However, a regression in NPC position editing changed those plans a little.   New   - You can now view lobbies through the new Other maps tab in the main menu. Exporting these maps isn’t available yet, I’ll add it in 1.0.0. - Export multiple NPCs as a single scene or as separate ones.   Improvements   - When exporting locations to Blender, terrain layers and masks are saved separately for editing. Grass and flowers use instancing, reducing file sizes and speeding up import. Fixed issues with empty material slots and seams at hidden terrain edges. - You can now specify a custom export scale.   Fixes   - Clicking an NPC now activates position editing, allowing you to move and rotate it.
  • 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..