Linked Questions
81 questions linked to/from File to byte[] in Java
75
votes
6
answers
175k
views
Elegant way to read file into byte[] array in Java [duplicate]
Possible Duplicate:
File to byte[] in Java
I want to read data from file and unmarshal it to Parcel.
In documentation it is not clear, that FileInputStream has method to read all its content. To ...
76
votes
9
answers
298k
views
how to convert image to byte array in java? [duplicate]
I want to convert an image to byte array and vice versa. Here, the user will enter the name of the image (.jpg) and program will read it from the file and will convert it to a byte array.
-1
votes
2
answers
76k
views
How to read bytes from a file to a byte[] array? [duplicate]
I am writing a Java program which encrypts a given text using RSA, and saves the encrypted bytes(byte[] array) in a .txt file. There is a separate decryption program which reads these bytes. Now I ...
0
votes
1
answer
19k
views
BufferedReader to byte[] [duplicate]
Need to load image to a byte[] variable.
File file = new File(context.getFilesDir(), body + ".image");
BufferedReader in = new BufferedReader(new FileReader(file));
How can I convert BufferedReader ...
0
votes
1
answer
6k
views
How to convert .mp4 video to byte array in Java? [duplicate]
So, I have this .mp4 video file which I would like to convert into bytes and send it to my client.
At client, I'll receive all the bytes over RTP and then construct my own .mp4 file.
Please help me ...
-1
votes
1
answer
6k
views
How to get the byte array from the file path in the array from? [duplicate]
I need to get the byte array from file path to upload the image. But the byte array in the form of array.How do i get the byte array. I have followed the following steps but could not found the ...
0
votes
2
answers
355
views
is this correct ? how to load bytes from a file? [duplicate]
I need to load bytes from a file using Java. is this right ?
InputStream ips=new FileInputStream(file);
InputStreamReader ipsr=new InputStreamReader(ips);
BufferedReader br=new BufferedReader(ipsr); ...
-1
votes
1
answer
771
views
How to read a large zip file data in byte array? [duplicate]
I am reading a large zip file but my code giving me negative array size exception
// Simplest read of an entire file into a byte array
// Will throw exceptions for file not found etc.
...
0
votes
0
answers
647
views
How to read a file using ByteArrayInputStream in java? [duplicate]
I have created a file called"output.txt" using this code snippet.
public static void main(String args[]) throws IOException{
BitSet bitset = new BitSet();
for(int i = 0; i<100; i++){
...
0
votes
1
answer
587
views
What is the reason my byte array is full of zeros after converting a file which have text init? [duplicate]
I am trying read a text file and insert those content into database.
My file.length() is 3540
But the byte array is full of zeros. As a result when I open the text file, it is empty.
File file = new ...
0
votes
1
answer
113
views
Need help importing a text file into byte[] for JDK 6 [duplicate]
This is the code I am using that retrieves data from a letter.txt file
File file = new File("/Users/Shiv/Eclipse/CPS3498/letter.txt");
FileReader fileReader = new FileReader(file);
...
292
votes
9
answers
530k
views
What is simplest way to read a file into String? [duplicate]
I am trying to read a simple text file into a String. Of course there is the usual way of getting the input stream and iterating with readLine() and reading contents into String.
Having done this ...
130
votes
8
answers
210k
views
Sending files using POST with HttpURLConnection
Since the Android developers recommend to use the HttpURLConnection class, I was wondering if anyone can provide me with a good example on how to send a bitmap "file" (actually an in-memory stream) ...
87
votes
2
answers
185k
views
Return generated pdf using spring MVC
I am using Spring MVC .I have to write a service that would take input from the request body, add the data to the pdf and returns the pdf file to the browser. The pdf document is generated using ...
47
votes
3
answers
28k
views
Android import java.nio.file.Files; cannot be resolved
I am trying out the new Gmail API and the samples use the classes in the java.nio.file package, e.i. Files and FileSystems.
These classes was introduced in Java jdk 1.7 for the record, and since I am ...