What to import to use IOUtils.toString()?
I am trying to use IOUtils.toString() to read from a file.
However, I am getting an error saying "IOUtils cannot be resolved."
What am I supposed to be importing to allow me to use this function?
String everything = IOUtils.toString(inputStream);
Thanks
java apache io tostring
add a comment |
I am trying to use IOUtils.toString() to read from a file.
However, I am getting an error saying "IOUtils cannot be resolved."
What am I supposed to be importing to allow me to use this function?
String everything = IOUtils.toString(inputStream);
Thanks
java apache io tostring
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19
add a comment |
I am trying to use IOUtils.toString() to read from a file.
However, I am getting an error saying "IOUtils cannot be resolved."
What am I supposed to be importing to allow me to use this function?
String everything = IOUtils.toString(inputStream);
Thanks
java apache io tostring
I am trying to use IOUtils.toString() to read from a file.
However, I am getting an error saying "IOUtils cannot be resolved."
What am I supposed to be importing to allow me to use this function?
String everything = IOUtils.toString(inputStream);
Thanks
java apache io tostring
java apache io tostring
edited Oct 16 '16 at 15:24
Philip Kirkbride
7,8882683149
7,8882683149
asked May 14 '13 at 4:17
user2380101
81114
81114
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19
add a comment |
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19
add a comment |
4 Answers
4
active
oldest
votes
import org.apache.commons.io.IOUtils;
If you still can't import add to pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
or for direct jar/gradle etc visit:
http://mvnrepository.com/artifact/commons-io/commons-io/2.5
Also since version 2.5 of commons-io method IOUtils.toString(inputStream) has been deprecated. You should use method with Encoding i.e.
IOUtils.toString(is, "UTF-8");
1
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
add a comment |
import org.apache.commons.io.IOUtils;
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
add a comment |
Alternatively you can try following way. It worked for me for reading public key for resource server
final Resource resource = new ClassPathResource("public.key");
String publicKey = null;
try {
publicKey = new String(Files.readAllBytes(resource.getFile().toPath()), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
add a comment |
Here is code for How to convert InputStream to String in Java using Apache IOUtils
Reference : https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html
FileInputStream fis = new FileInputStream(FILE_LOCATION);
String StringFromInputStream = IOUtils.toString(fis, "UTF-8");
System.out.println(StringFromInputStream);
Let me know if you need more help.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16535032%2fwhat-to-import-to-use-ioutils-tostring%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
import org.apache.commons.io.IOUtils;
If you still can't import add to pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
or for direct jar/gradle etc visit:
http://mvnrepository.com/artifact/commons-io/commons-io/2.5
Also since version 2.5 of commons-io method IOUtils.toString(inputStream) has been deprecated. You should use method with Encoding i.e.
IOUtils.toString(is, "UTF-8");
1
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
add a comment |
import org.apache.commons.io.IOUtils;
If you still can't import add to pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
or for direct jar/gradle etc visit:
http://mvnrepository.com/artifact/commons-io/commons-io/2.5
Also since version 2.5 of commons-io method IOUtils.toString(inputStream) has been deprecated. You should use method with Encoding i.e.
IOUtils.toString(is, "UTF-8");
1
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
add a comment |
import org.apache.commons.io.IOUtils;
If you still can't import add to pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
or for direct jar/gradle etc visit:
http://mvnrepository.com/artifact/commons-io/commons-io/2.5
Also since version 2.5 of commons-io method IOUtils.toString(inputStream) has been deprecated. You should use method with Encoding i.e.
IOUtils.toString(is, "UTF-8");
import org.apache.commons.io.IOUtils;
If you still can't import add to pom.xml:
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>
or for direct jar/gradle etc visit:
http://mvnrepository.com/artifact/commons-io/commons-io/2.5
Also since version 2.5 of commons-io method IOUtils.toString(inputStream) has been deprecated. You should use method with Encoding i.e.
IOUtils.toString(is, "UTF-8");
edited Jun 6 '16 at 22:43
answered Jun 6 '16 at 22:20
Fryta
24726
24726
1
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
add a comment |
1
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
1
1
it worked with me
– user1
Sep 25 '16 at 15:03
it worked with me
– user1
Sep 25 '16 at 15:03
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Is it deprecated in favor of what method?
– Raffael Bechara Rameh
Apr 4 '17 at 16:50
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
Same method name but with one additional parameter - encoding. 'IOUtils.toString(is, "UTF-8");'
– Fryta
Apr 9 '17 at 21:10
add a comment |
import org.apache.commons.io.IOUtils;
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
add a comment |
import org.apache.commons.io.IOUtils;
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
add a comment |
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.IOUtils;
edited Nov 23 '18 at 5:27
SMR
5,58222751
5,58222751
answered Sep 30 '13 at 18:20
kracejic
375314
375314
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
add a comment |
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
3
3
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Unable to import this. Please help
– Vaibhav Jhaveri
Apr 21 '15 at 11:50
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
Check the answer of @Fryta, you need to add a library to your project.
– thuanle
Feb 23 '17 at 3:58
add a comment |
Alternatively you can try following way. It worked for me for reading public key for resource server
final Resource resource = new ClassPathResource("public.key");
String publicKey = null;
try {
publicKey = new String(Files.readAllBytes(resource.getFile().toPath()), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
add a comment |
Alternatively you can try following way. It worked for me for reading public key for resource server
final Resource resource = new ClassPathResource("public.key");
String publicKey = null;
try {
publicKey = new String(Files.readAllBytes(resource.getFile().toPath()), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
add a comment |
Alternatively you can try following way. It worked for me for reading public key for resource server
final Resource resource = new ClassPathResource("public.key");
String publicKey = null;
try {
publicKey = new String(Files.readAllBytes(resource.getFile().toPath()), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
Alternatively you can try following way. It worked for me for reading public key for resource server
final Resource resource = new ClassPathResource("public.key");
String publicKey = null;
try {
publicKey = new String(Files.readAllBytes(resource.getFile().toPath()), StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
answered Oct 21 '18 at 13:43
snj
809
809
add a comment |
add a comment |
Here is code for How to convert InputStream to String in Java using Apache IOUtils
Reference : https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html
FileInputStream fis = new FileInputStream(FILE_LOCATION);
String StringFromInputStream = IOUtils.toString(fis, "UTF-8");
System.out.println(StringFromInputStream);
Let me know if you need more help.
add a comment |
Here is code for How to convert InputStream to String in Java using Apache IOUtils
Reference : https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html
FileInputStream fis = new FileInputStream(FILE_LOCATION);
String StringFromInputStream = IOUtils.toString(fis, "UTF-8");
System.out.println(StringFromInputStream);
Let me know if you need more help.
add a comment |
Here is code for How to convert InputStream to String in Java using Apache IOUtils
Reference : https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html
FileInputStream fis = new FileInputStream(FILE_LOCATION);
String StringFromInputStream = IOUtils.toString(fis, "UTF-8");
System.out.println(StringFromInputStream);
Let me know if you need more help.
Here is code for How to convert InputStream to String in Java using Apache IOUtils
Reference : https://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/IOUtils.html
FileInputStream fis = new FileInputStream(FILE_LOCATION);
String StringFromInputStream = IOUtils.toString(fis, "UTF-8");
System.out.println(StringFromInputStream);
Let me know if you need more help.
answered Feb 17 '15 at 7:00
Himanshu Arora
118211
118211
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f16535032%2fwhat-to-import-to-use-ioutils-tostring%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use this.. stackoverflow.com/questions/14768166/ioutils-exception-android
– Ahmed Z.
May 14 '13 at 4:19