Questions tagged [fileinputstream]
FileInputStream is a Java class meant for reading streams of raw bytes.
1,088
questions
-3
votes
2answers
69 views
Is there an -1 at the end of an Inputstream?
I am quite new to programming.
While reading the article Byte Streams in "Basic I/O" in The Java Tutorials by Oracle, I came accross this code:
import java.io.FileInputStream;
import java.io....
0
votes
0answers
10 views
How to copy the SQLITE audio file to internal or external storage using input output stream?
I am trying to copy the audio file from SQLITE DB to internal storage of mobile device, which I tried using File input output stream , but the audio file is not copied , and also I did not get any ...
-1
votes
1answer
58 views
Why is my scanner reading numbers in a text file as a string?
I have a text file that has grocery items followed by the isle they are on in a text file. For some reason, my scanner is only picking up on the data as a string and not a string and an int. Below is ...
0
votes
1answer
51 views
Java ObjectInpuStream reading DefaultTableModel [closed]
There is a class saving a DefaultTableModel of an other class.
file_path = new File( "c://Database//Directory//" );
file_table_stock_save = new File( file_path , "stockfile.file" )...
1
vote
0answers
17 views
How to extract frames from video with pipe and read it every 1 second?
I am trying to use pipe to extract frames from a video to get better-extracting performance. It took me 1s to extract a 1080x720 frame from the video. So, my idea is to use pipe protocol and while ...
0
votes
0answers
23 views
Java hangs at readObject() (FileInputstream)
My program is hanging when it invokes readObject in FileInputStream.
I am not using a socket connection or anything like that, nor am I using an output stream (except for console output).
here is the ...
0
votes
2answers
23 views
While Downloading xls file in webapp showing invalid file content
I am using below code to download and show the xls file from my webapp. file downloading with invalid characters (like 䡗ⰱㅂ〬ⰱ). Please let know what I am missing in this code.
byte servletBytes[] = ...
1
vote
1answer
28 views
Copy an image bit by bit C++
I recently found some documentation on file open modes in C++ and, using ios_base::binary, tried to open an image (.JPG), read the bits one by one, and write them in a separate file (ofstream) with a ....
0
votes
1answer
29 views
Java - Download PDF from bytes which are coming as string?
We are calling some API which is returning bytes as String and I need to download PDF from that byte stream (which is coming as String).
e.g.
download_pdf":[{"name":"...
1
vote
1answer
31 views
MyClass.class.getResourceAsStream of a json file return zip file
in my java web-app I have integrated firebase-admin-sdk. To go to retrieve the json file to pass to GoogleCredentials I use MyClass.class.getResourceAsStream (path), doing the cast as follows:
...
0
votes
0answers
21 views
Reading in an uneven file to a struct
I know how to read in a normal file into a struct but how do I do a file that has an uneven amount of elements like
John Smith 56
Katie Smith 52 38
Jane Doe 89 28
Currently I am doing it where Names ...
0
votes
0answers
32 views
How to get the path to file in Spring Boot to use it as an argument in another library method?
I need a way to get a resource path in Spring Boot because I will use this path as an argument to another method in existing library, which I cannot change.
It is used as:
FileInputStream fis = new ...
0
votes
3answers
56 views
how to return FileInputStream ?? in java [duplicate]
package asasaSASA;
import java.io.*;
class FileInputTest {
public static FileInputStream f1(String fileName) {
try {
FileInputStream fis = new FileInputStream(fileName);
...
0
votes
0answers
13 views
How to read a HashMap by using FileInputStream
I having problems to read a .bin file that contains a HashMap. the HashMap key is a Integer and The HashMap value is a ArrayList<ArrayList<Sprite>> ( Sprite it's a class of my project, but ...
1
vote
0answers
107 views
Android how to post InputStream by chunks using okhttp
I have an issue with FileInputStream on Android with Kotlin and Okhttp. I want to post a video file by using an API, but if this file is bigger than 128mb I have to upload it chunk by chunk.
So, in my ...
0
votes
1answer
31 views
Appending to ObjectOutputStream does not change anything
Here's my problem. In my DetailActivity I check to see whether a File is empty or not. If it is, I create a new File and write an object to that file no problem. If it isn't, this means the file has a ...
0
votes
0answers
28 views
How to create File from list of byte arrays in Android?
I am trying to transfer a .mp4 file using WebRTC and it's DataChannel. In order to do that I am breaking the file into chunks like below:
FileInputStream is = new FileInputStream(file);
byte[] chunk = ...
0
votes
1answer
32 views
Passing a BufferedImage into a FileInputStream meant for image files
I have two independant pieces of code that I need to work together, one written by myself and one that is from another project. I essentially have one part of the project that is creating a buffered ...
2
votes
1answer
72 views
Sonarqube - performance issue as Method uses a FileInputStream constructor, what are the better alternatives?
Here is my code :
KeyStore truststore = KeyStore.getInstance("JKS");
truststore.load(new FileInputStream(TRUSTSTORE_FILE),
...
0
votes
2answers
43 views
Why I cannot read List object from my file (Java IO) [duplicate]
I have a method writing List<String> into file like this:
public static void main(String[] args) {
List<String> data = Arrays.asList("1", "2", "3", "...
0
votes
2answers
39 views
Difference between FileInputStream.read(…) and RandomAccessFile
I am new to Random File Access, and I have encountered one issue - as far as I have understood, RandomAccessFile class provides a Random Access file for reading/writing. I can use seek() method to ...
0
votes
1answer
45 views
How to read the content of all of the text files of a directory using Java?
My problem is that I want to iterate all the text files in a directory using Java but whenever I start for loop over files, it always results in half processing, like for example:- I have 80 files and ...
1
vote
0answers
35 views
Logstash with XML file
We are using logstash to read an xml file. This xml file is generated when a Jenkins pipeline build commences and is written to with build data during the pipeline execution. We use file input mode '...
0
votes
0answers
13 views
Android: Is it possible to change the destination that a fileDescriptor writes to?
I am trying a new approach to continuous video recording in Android. I plan to link the mediaRecorder to a fileDescriptor. If I invoke mediaRecorder.pause(), can I change the destination that the ...
0
votes
0answers
22 views
How to get the content of a file uploaded with HTML input file using Java?
I am trying to get the content of a file uploaded using a HTML input type=file and store it into a database.
It's been done with JavaScript, but I need to do it with Java specifically(I am using the ...
0
votes
0answers
24 views
Getting a FileInputStream to work reading in a WAV file in Android Studio project [duplicate]
I have a separate class in an Android Studio project that analyzes WAV files. I debugged the file originally in Eclipse and now have loaded it into Studio. Unsurprisingly, I'm having trouble reading ...
0
votes
1answer
34 views
How to pass CSVReader object as call by value instead of call by reference in java?
Java is a Call By Value but when I am passing CSVReader object it is working as a Call by reference.
private CSVReader csvReader=null;
public String getColumn(String filePath, String tagValue, int ...
0
votes
0answers
30 views
XSSFWorkbook constructor with string or InputStream
I've some simple code which reads and writes to an excel file. What I don't understand is why do I get
"Unexpected end of ZLIB input stream" if I use method 1 to read the file but no errors ...
-2
votes
1answer
36 views
Insert new line after every line in python
absolute novice to python here just trying to automate some processes. After doing some research, i have understood that fileinput can be used to open, read, and write to files in python. In order to ...
0
votes
2answers
186 views
Getting “java.io.IOException: Stream closed”, when trying to read file from relative path
I am trying to read yaml file. At first i had absolute path,it was working fine. Now when i have war file to be deployed in server,i want to change the absolute to relative path. From then it is ...
0
votes
2answers
42 views
Reading Binary file from FileINputStream
Getting null pointer exception when program enters while loop
File p1 = new File("file.EXE");
FileInputStream in1 = new FileInputStream(p1);
byte[] b1 = new byte[16];...
-1
votes
1answer
37 views
Creating files from ByteArrayOutputStream
I am trying to create separate files from ByteArrayOutputStream (Here byteOut is my ByteOutputStream). The following code does the job
final InputStream targetStream = new ByteArrayInputStream(...
0
votes
1answer
64 views
When would I use BufferedInputStream?
Why do I wrap FileInputStream with BufferedInputStream and use read(byte[20]) and let
BufferedInputStream buffer internally with 8192 bytes for performance benefits?
Instead I can use fileInputStream....
0
votes
1answer
35 views
when I am trying to upload file using java am getting this error The system cannot find the file specified (tmp)
I am generating a temp file in my cash C drive it's only generating one file the second one is not generating and I am getting this error:
The system cannot find the file specified (tmp)*
...
0
votes
1answer
33 views
Can't write file to internal storage Android
I am trying to save a user history to the internal storage, which seems to work (no error) :
Gson gson = new Gson();
String json = gson.toJson(userHistory);
historyFile = new ...
0
votes
0answers
22 views
Why do ImageView class setImage methods get ignored when there is a second setImage method beneath the first one? [duplicate]
I'm trying to display 2 images on user mouse click. The first image should be displayed, then a pause occurs, and then the second image displays.
Ultimately I want both images to display one right ...
0
votes
1answer
43 views
How do I read from a .txt file inside of a resource directory folder?
Here's what I need to happen: I've got a text file with some values in them that I need to read (Let's say it is example.txt). I need to read that file like i would using ex. FileInputStream or ...
0
votes
1answer
27 views
Cannot Find and Read Text File on Android Studio (Java)
So I am creating a mobile application using Android Studio that allows the user to randomize and generate a character. I am trying to read a .txt file of the characters' names, line by line, so that I ...
-1
votes
1answer
42 views
How does the FileInputStream class knows the offset when the read method is called again and again?
Here I am using FileInputStream class to read data from input.txt. read method is called twice. How does the inputStream object know that it has to read the second character when the read method is ...
0
votes
5answers
60 views
Output when I read in a txt.file with numbers in each line
I want to read the numbers from the following text file:
5
8
-2
11
3
-5
2
10
This is my java code:
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
public class Solution {
...
0
votes
0answers
9 views
Number Stats C++
Having an issue where my input file is not being opened when the code is ran, no errors are present but the txt file just is not being used so it just kicks me into the "file not found" ...
0
votes
0answers
34 views
How can I duplicate updates across mutiple files contents using Java?
I have one text file, if any modifications happen or content is added in the first file, they will be updated into a second file automatically.
How can I do this using Java?
0
votes
0answers
54 views
Converting FileInputStream to Array[Byte] Scala
I would convert a FileInputStream to Array[Byte] in Scala 2.13 without using Apache Commons IO. How can I do that?
0
votes
0answers
21 views
How do FileInputStream and FileOutputStream hold internal state?
Looking at this standard code except for copying bytes, I'd like to know, how the streams hold their internal state.
InputStream in = new FileInputStream(...);
InputStream out = new FileOutputStream(.....
0
votes
0answers
30 views
Passing file location as a parameter in to File(String) showing error
I have properties file where I have specified the file location. In property file below value is given. Below path have 2 text files named 1 and 2.
FileLoc="C://users//test"
In Java file I ...
0
votes
1answer
15 views
Sharing file create by an app in MODE_PRIVATE
So I have an app which writes sensor data to a csv file via FileOutputStream in MODE_PRIVATE
FileOutputStream fos = null;
try {
fos = context.openFileOutput(FILE_NAME,Context....
1
vote
2answers
503 views
Read and copy file with Coroutines
I created the following application to illustrate some doubts. My Example on the Github
In this example, I copy a file to another package.
My doubts are as follows:
Performing the tasks in parallel, ...
0
votes
0answers
21 views
Android Studio: open a file through SAF and pass it to FileInputStream
Is there a way to choose a file on SAF and pass it to FileInputStream?
I saw another post that suggests to use contentResolver.openInputStream(uri), but I wonder if it's possible to use ...
0
votes
1answer
23 views
what is the best way to create rest api to accept html template as an input?
I am using springboot and I need to create Rest APi that will take html template as a parameter. what is the best practice to do that? should I deal with it as @File and save the file in my directory ...
0
votes
1answer
22 views
File Object or Path to pass for creating FileInputStream instance
We have two constructors of the class FileInputStream as below.
public FileInputStream (String path)
public FileInputStream (File file)
When we should go for the second approach? Even to create a ...