Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need equivalent of Java's DataInputStream and DataOutputStream #31166

Closed
markmclaren2 opened this issue Oct 20, 2017 · 3 comments
Closed

Need equivalent of Java's DataInputStream and DataOutputStream #31166

markmclaren2 opened this issue Oct 20, 2017 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue

Comments

@markmclaren2
Copy link

markmclaren2 commented Oct 20, 2017

I'm trying to do in Dart what I would do in Java like this:

DataOutputStream dout = new DataOutputStream(new FileOutputStream("test.bin"));
out.writeInt(123);
out.writeFloat(4.0f);
out.writeUTF("Hello");

DataInputStream in = new DataInputStream(new FileInputStream("test.bin"));
int x = in.readInt();
float y = in.readFloat();
String name = in.readUTF();

A similar issue raised in 2012 has been closed with the comment "By using dart:typeddata and the new IOSink(writeBytes), it's now possible to do this". Well it may be possible, but it is far from clear to me how to do it. Could someone please show how to rewrite the above code in Dart?

If it takes more than 10 lines, please consider adding specialised classes to dart like this one by TomCaserta. (Tom's version is lacking in that it doesn't handle streams, doesn't implement readLong properly, and has a bug when trying to read a UTF string at the end of the byte array)

@kasperl kasperl added the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Oct 25, 2017
@lrhn
Copy link
Member

lrhn commented Oct 1, 2020

Not planning this for the platform libraries. It might be a good fit for package:typed_data.

@lrhn lrhn closed this as completed Oct 1, 2020
@lrhn lrhn added the closed-not-planned Closed as we don't intend to take action on the reported issue label Oct 1, 2020
@Binozo
Copy link

Binozo commented Mar 27, 2023

Still no real equivalent in 2023

It seems like Java's socket and Dart's socket io behave differently

@Hellomik2002
Copy link

Is there any solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue
Projects
None yet
Development

No branches or pull requests

5 participants