java-io Questions
2
Solved
Im making a simple TCP/IP Socket app
Whats the different between doing this:
DataInputStream in = new DataInputStream(clientSocket.getInputStream());
byte[] buffer = new byte[100];
in.readFully(...
11
Solved
I have around 500 text files inside a directory with each with the same prefix in their filename, for example: dailyReport_.
The latter part of the file is the date of the file. (For example dailyR...
7
Solved
java.io has many different I/O streams, (FileInputStream, FileOutputStream, FileReader, FileWriter, BufferedStreams... etc.) and I am confused in determining the differences between them. What are ...
6
Solved
4
i'm trynig to develop a REST web service using CXF 2.6.0 and spring 2.5.6 my CXF maven dependancy in the pom.xml are :
<dependency>
<groupId>org.apache.cxf</groupId>
<artif...
3
I am trying to read /proc/net/xt_qtaguid/stats in Android 6.
Using cat command, I get this:
2 a0 0 0 123456 311 48329 737 48 1
3 b0 0 0 0 0 0 0 0
4 c0 123456 311 48329 737 48 1
5 d0 111111 111 222...
Falconiform asked 15/6, 2017 at 14:8
4
Solved
I know that the PrintWriter is really good if we want to write formatted data, and I also know the use of BufferedWriter to improve IO performance.
But I tried something like this,
PrintWriter pw...
Dainedainty asked 24/8, 2015 at 8:30
4
Solved
I am trying to open files with FileInputStream that have whitespaces in their names.
For example:
String fileName = "This is my file.txt";
String path = "/home/myUsername/folder/";
String fileP...
3
Solved
Today I tried to refactor this code, that reads ids from files in a directory,
Set<Long> ids = new HashSet<>();
for (String fileName : fileSystem.list("my-directory")) {
InputSt...
Mcgruter asked 25/4, 2017 at 11:10
3
I'm trying to unmarshal my xml file:
public Object convertFromXMLToObject(String xmlfile) throws IOException {
FileInputStream is = null;
File file = new File(String.valueOf(this.getClass().getR...
Burdick asked 4/4, 2016 at 16:5
2
Solved
How can I get the bytes of an outputStream, or how can I convert an outputStream to a byte array?
Circum asked 28/3, 2017 at 22:21
4
Solved
IMO having both of these methods is redundant and really unclear!
i can't quite understand why both of these methods are designed in Files API ??
Files.exist(..) returns true if file really exist ...
10
Solved
I use the Eclipse IDE to develop, compile, and run my Java projects. Today, I'm trying to use the java.io.Console class to manage output and, more importantly, user input.
The problem is that Syst...
1
Solved
Sonar is giving an error that this FileOutputStream should be closed. I need to modify the following code to use try-with-resources. How do I do this?
public void archivingTheFile(String zipFile){...
Pinnatifid asked 20/12, 2016 at 18:0
2
Solved
I have the below code got from mkyong, to zip files on local. But, my requirement is to zip files on server and need to download that. Could any one help.
code wrote to zipFiles:
public void zipF...
4
Solved
I need to create files under myapp/files/subdir with global permission in my application. I do this because I use external applications to open some files
Using this
FileOutputStream fos = openF...
Calices asked 25/10, 2011 at 8:58
4
Solved
I get compilation error when I do this cast:
RandomAccessFile raf = new RandomAccessFile(...)
InputStream is = (InputStream)raf;
RandomAccessFile is supposed to subclass InputStream although not...
1
Solved
I've noticed that java.io and java.nio implementations of random access files differ slightly with respect to how FileLocks are handled.
It appears as though (on Windows) java.io gives you a manda...
Fiertz asked 2/9, 2016 at 13:5
4
Solved
It's perfectly described here how to do it, the only problem: He doesnt know the function openFileOutput();
private void saveSettingsFile() {
String FILENAME = "settings";
String string = "hello...
Infective asked 2/9, 2010 at 14:23
1
I have a text file with 500 lines. I placed this text file in app/src/main/assets folder with the name "words.txt". In this file each line is separated with line break. Now i need to get random lin...
Mellicent asked 19/8, 2016 at 7:11
3
Solved
I'm unable to think of a realistic use case for the method java.io.File.exists() or its equivalent in Java 7 java.nio.file.Files.exists(Path). It seems that isFile() or isDirectory() would be prefe...
Trill asked 11/12, 2013 at 15:33
4
Solved
In my online computer science class I have to write a program to determine the surface gravity on each planet in the solar system. I have gotten almost every aspect of it to work save one. I need t...
Canthus asked 21/1, 2013 at 17:5
2
Solved
In my application I read file using following method,
public void readFIleData(String path) {
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader(path))...
7
I'd like to convert gif images to jpeg using Java. It works great for most images, but I have a simple transparent gif image:
Input gif image http://img292.imageshack.us/img292/2103/indexedtestal7...
Paresthesia asked 21/1, 2009 at 10:58
10
Solved
Note: This question and most of its answers date to before the release of Java 7. Java 7 provides Automatic Resource Management functionality for doing this easilly. If you are using Java 7 o...
© 2022 - 2024 — McMap. All rights reserved.