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

Write directly to a String #97

Closed
yamin8000 opened this issue Apr 11, 2022 · 6 comments
Closed

Write directly to a String #97

yamin8000 opened this issue Apr 11, 2022 · 6 comments
Labels
enhancement New feature

Comments

@yamin8000
Copy link

is there any way to write to a String instead of a File?

@doyaaaaaken
Copy link
Owner

Sorry, this library supports output formats only as java.io.File or OutputStream.

@yamin8000
Copy link
Author

Sorry, this library supports output formats only as java.io.File or OutputStream.

The preference of only outputting to a File or OutputStream seems somewhat opinionated or even questionable to me.
It can be beneficial to output directly to a String like when you want to send data in Android to other apps or share data using Intent or hell this library is so easy to use and usable one can use it for raw-printing database records in logs or a TextView for testing purposes or even usable in back-end programming and you just want to respond to an API call with a CSV representation of some data records from the database, that's just my two cents.
For now, I can live with writing to a temporary file in the cache and read that same file so I can have it as a String.

@doyaaaaaken doyaaaaaken added the enhancement New feature label Apr 12, 2022
@doyaaaaaken
Copy link
Owner

Thanks for the feedback.
I think it's a good idea. I'll consider addressing this issue.

For now, I can live with writing to a temporary file in the cache and read that same file so I can have it as a String.

Yes, it's a valid workaround for this problem.

@Thijsiez
Copy link
Contributor

Not sure if this would work for your use case, but maybe writing an extension function that does something like the following would be helpful
val output = String(outputStream.toByteArray(), Charsets.UTF_8)

@doyaaaaaken
Copy link
Owner

@Thijsiez Good solution!! Thanks!

doyaaaaaken added a commit that referenced this issue Aug 7, 2022
doyaaaaaken added a commit that referenced this issue Aug 7, 2022
doyaaaaaken added a commit that referenced this issue Aug 7, 2022
@doyaaaaaken
Copy link
Owner

Released in version 1.6.0.
Thanks, @Thijsiez !! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature
Projects
None yet
Development

No branches or pull requests

3 participants