Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I have an issue where sending strings with the PacketHandler inserts some wierd null chars and doesnt send along some chars.

I'm currently using this code to send strings:

            ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
	DataOutputStream dataStream = new DataOutputStream(byteStream);

	try{
		dataStream.writeChars(str + "\n");
		PacketDispatcher.sendPacketToServer(PacketDispatcher.getPacket(ModInfo.CHANNEL, byteStream.toByteArray()));
	}catch(IOException ex){
			System.err.append("Faild to send String");
	}

 

and this to recieve:

 

String str = reader.readLine();

 

What am I doing wrong, or whats the proper way of sending strings?

 

 

for me,that works better.


       //reciving string
    	int n=data.readInt();
    	for (int i=0;i<n;i++) 
    		name=name+data.readChar();

       //sending string

    	out.writeInt(name.length());
    	int n = name.length();
    	for (int i=0;i<n;i++) 
    		out.writeChar(name.charAt(i));

  • Author

Thanks for the answers!

readUTF and writeUTF works perfectly for me.

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.