Read binary file and convert to readable text
I have a binary file which i want to read in and then convert it into readable text. How can i do this?
I have a binary file which i want to read in and then
convert it into readable text. How can i do this?Your question is a bit too vague to be answered. Here's an example -- suppose a file contains the bitstream 11011110101011011011111011101111. (just four bytes full of bits). If one 'converts' this bit stream using four byte big-endian integral values into a hexadecimal representation, the outcome would be 'deadbeef'. Using a little endian conversion, the outcome would be 'efbeadde'. All three text strings you're reading right now (the binary one, and both hexadecimal versions) are readable representations of the actual bitstream ... which one do you want?
OTOH, if you want to know what's stored in a .class file (this is a Java forum isn't it?), have a look at 'pjava'; it comes with your SDK.
kind regards,
Jos
Similar Messages
-
How to read flat file and convert to xml throught OSB
Hi ,
Can somebody help how to read flat file and convert to xml in OSB.
appreciate ur help.
Thanks & Regards ,
Siva K Diviif you're using the oepe with osb plugin (will be installed when you install the osb locally) and then in your osb project > rightmouseclick > new > MFL.
that's it
maybe you're trying to create it within an oepe installation which doesnt have the osb plugin ? -
Read linux lastlog file and convert to a String
Hi
I am trying to read the data from the lastlog file in Linux. I think this is a binary file encoded in ASCII. How would I go about reading this file and converting the binary data into a String and then displaying the data? Each bit of data is separated by a new line to distinguish between the different values.
Many Thanks
Sambo"Binary file encoded in ASCII"? Well, you'd have to find out what encoding was used and then reverse is.
As for reading files in general, check here:
http://java.sun.com/docs/books/tutorial/essential/io/index.html -
Read Binary File, Help me! Thanks!
I want to read a binary file and tried several times,
but failed, who can give me an example?
Thank you !Thank you very much! my codes are listed below
i want to read a binary file and convert to ASCII.
import java.io.*;
public class FileInputDemo
public static void main(String args[])
if (args.length == 1)
try
FileInputStream fstream = new FileInputStream(args[0]);
DataInputStream in = new DataInputStream(fstream);
while (in.available() != 0)
System.out.println(in.readLine());
in.close();
}catch (Exception e)
{System.err.println("File input error");}
else
{System.out.println("Invalid parameters");}
} -
How to open and read binary files?
How do I open and read Binary files?
Did you look on The Unarchiver's web site where it has a link to older versions? http://theunarchiver.googlecode.com/files/TheUnarchiver3.2_legacy.zip
The best thing to do is ask your friends what programs they used to produce these files, or at least what format files they are producing. Otherwise it's like being shown a car and given a bundle of 200 keys with no idea to which one to use, or even if any of them work with that car.
Using The Unarchiver will likely not do anything because it too will not know what format files are involved, and they may not even been in an archived format. If they sent you a Word file without telling you (a favorite of Windows users to do -- it drives me crazy when they could have just sent them in plain text), The Unarchiver won't open them. If it's a picture file then using Hexedit will just show you a bunch of unintelligible stuff as shown in an earlier post, though you may see a line of text providing a hint.
As I said earlier, often .bin may be an executable program which needs another program to actually interpret it. That's what Java is trying to do. Still, it may think it can execute the file, but it is highly unlikely somebody would send you an executable program (and if they did I would not trust it). For all you know it may be a Windows virus. -
Read bytes in file and print in clear text
Hi
I'm using hsql and use cached tables. This results in all data beeing stored in a binary file (Some of the data is stored in plain text though, but encrypted). The binary data starts and ends with ' (singlequote), the format is hexadecimal. How can I read this file and present all data in plain text, there is no need to decrypt the encrypted strings though.
Example of how the data is stored in the file:
W@ ` � M 43.6 Torticollis (nacksp��rr) h � X M 50 !Disksjukdom med halsryggssm��rtor � p � M 50.0 *Diskbr��ck i halskotpelaren med myelopati � p � 0 M 50.1 ,Diskbr��ck i halskotpelaren med radikulopati X h 0 M 50.2 !Annat diskbr��ck i halskotpelaren � p � � X M 50.3 'Annan diskdegeneration i halskotpelaren 0 `I have some questions..
This results in
all data beeing stored in a binary file (Some of the
data is stored in plain text though, but encrypted).Encrypted text is binary data.
The binary data starts and ends with ' (singlequote),In your example, where is the '
the format is hexadecimal. In your example, I cannot see any hexidecimal formatted data.
Hexidecimal would look like: ABFEFDC8214634896FA8623EDB
How can I read this fileThe same way you would read any other file.
and present all data in plain text, there is no need
to decrypt the encrypted strings though.If you cannot decyrpt the string, it is not going to be in plain text, I fear.
Do you mean you want to see a binary file as hexidecimal? -
Hi, I have used PDF export for some years. One file will NOT convert to readable text in Word. Some headers and maps in this document are converted OK but the body text is garbled. I have tried converting to Docx, Doc and RTF with no success. I disabled OCR and it made no difference. What can I do please?
LesHi,
Can you please provide me the file with which you are facing the issue.
Thanks -
After reinstalling CS6 the bridge photo downloader isn't able to read raw files and fails to convert the raw files to DNG. Previously downloaded raw files, now DNG, open up successfully in Camera Raw 7. How do I get the photo downloader to read and convert raw files. MacBook Pro with Snow Leopard. No such problem before this reinstallation.
You should install Camera Raw 4.6.
Visit this page and follow the instructions carefully:
PC: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4040
Mac: http://www.adobe.com/support/downloads/detail.jsp?ftpID=4039
-Noel -
Reading in any file and converting to a byte array
Okay what I am trying to do is to write a program that will read in any file and convert it into a int array so that I can then manipulate the values of the int array and then re-write the file. Once I get the file into an int array I want to try and compress the data with my own algorithm as well as try to write my own encryption algorithm.
What I have been looking for is code samples that essentially read in the file as a byte array and then I have been trying to convert that byte array into an int array which I could then manipulate. So does anyone have any sample code that essentially takes a file and converts it into an int array and then converts it back into a byte array and write the file. I have found code that is close but I guess I am just too new to this. Any help would be appreciated.You can read a whole file into a byte array like this:File f = new File("somefile");
int size = (int) f.length();
byte[] contents = new byte[size];
DataInputStream in = new DataInputStream(
new BufferedInputStream(new FileInputStream(f)));
in.readFully(contents);
in.close();Note that you need to add in the proper exception handling code. You could also use RandomAccessFile instead of the DataInputStream.
Writing a byte array to a file is easier; just construct the FileOutputStream, call write on it with the byte array, and close the stream. -
Write string (7 chars), int16, sgl into binary file and read it in C
How to write write string (7 chars), int16, sgl, string (5 chars) into binary file and then read it in C ?
Total 18 Bytes file (binary) should be created.Hi,
this could be done that way:
You have to make sure the strings have their correct length!
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
How to read binary files wrt specific BYTE size and length??
Hello Everyone,
I have a project I want to accomplish. I have a binary file, and I would like to read the data and print on wfm in a specific order and size.
The data is 16 bit binary type , and needs to be read in chunks of 2 bytes.
i have 30 bytes of sample 1.
followed by 2 bytes of sample 2.
followed by another 2 bytes of sample 3.
steps 2-4 should be repeated 10 times and then i should read sample 4 which is of 2 bytes.....
How should I do it?? I don't have any VI build... all i have is the example VI...
can anyone pleasehelp me???
Now on LabVIEW 10.0 on Win7smercurio_fc, sorry for the confusion, i will try my best to explain...
1. No, i don;t have to read the file again, once it has read, I used
while loop just to see the data updating (i press run, and before i can
visualize i have the waveforms; i can get rid of the while loop)
2. I have 30 different values of 1 sample. actually, the data is cmg
from tri-axial accelerometer; each axis is of 10 bytes(hence 3*10 =
30bytes)
3. I am repeating the steps 2-4 10 times because the data was written
into the binary file after 10 times sampling the sensors(if first 3
samples are read @ 1000hz, sample 4 was read at 1000/10 = 100hz)
4. I am using the graphs to interpret the values, that's it. The
values are already scaled when they were wrote to the binary file, I
have to simply interpret it.
I have made some changes in the VI, now i am reading only the first
30bytes, that too, in chunks of 10-10-10 bytes, and plotting the 3
samples simultaneously on a waveform chart. (will approach 1
sensor/sample at a time) and running the loop for 10 times. I have changed I8 to I16 now.
Please let me know if it makes sense to you now.
P.S. each sample is a sensor data.
Now on LabVIEW 10.0 on Win7
Attachments:
data_read.vi 24 KB -
Read binary file 10 bytes at a time
I want to read binary file in a specific format. There is a number at the starting of the file. That tells us where the data is starting. Suppose it says 3975, then it mean data starts at 3975. Then once I read that location I want to read data at 10bytes at a time and then convert it to numeric and display it on graph. I am attaching the file format and the current vi which I am using. please help.
Solved!
Go to Solution.
Attachments:
topo.zip 89 KBAh, the first 10 characters are a string!
After opening the file, use the Read From Text File with count set to 10. Then use the Decimal String to Number to convert this string into your "record size".
NOTE: The text indicator was just for debug purposes. You don't really need it.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Read record size.png 12 KB -
How to read binary file into a 2D float array??
Hi All,
I really need help to get this one as I am stuck and can't seem to find any way out of it. I am given a '.dat' file that has float values in it. I want to read this file in java and put it in a 2D float array. The file has basically a matrix of float values. What I want to do is to read this binary file and put all its data into 2D float array (float [] []) so that I can use it in my program. Is there a way to read file like this? I did find a similar matlab code (below) but cant seem to find anything in java and i really want to do this in java only.. I will appreciate ur help in this one.
thanks very much
Nitya
fid = fopen('datafile.dat');
A = fread(fid,[50 50],'float32');
fclose(fid);I shud have shown the two ways that i Already tried. here they are..
first one using DataInputStream and then trying to readFloat()
DataInputStream dis = ....
Float f = dis.readFloat();This code gives code gives me some random values like this.. (i had a loop)
5.8758974E-14
-0.41055492
1.5724557E-30
1.06822824E14
-1.91934371E15
3.43829601E13
Other way i tried was this.. which seems right but here i have to convert byte to float and i thnk that code is giving some different results (slightly different float values) not sure why....may be my indexing of the array is wrong to make it a matrix.. or something else...
is.read(bytes, offset....);
int cnt = 0;
int j = 0;
for (int start = 0; start < offset; start = start + 4) {
if(j<50){
myarray[cnt][j] = this.arr2float(bytes, start);
System.out.println(cnt + "-" + j + " = " + myarray[cnt][j]);
j++;
}else{
if(cnt < 50){
cnt++;
j = 0;
}else{
break;
public float arr2float (byte[] arr, int start) {
int i = 0;
int len = 4;
int cnt = 0;
byte[] tmp = new byte[len];
for (i = start; i < (start + len); i++) {
tmp[cnt] = arr;
cnt++;
int accum = 0;
i = 0;
for ( int shiftBy = 0; shiftBy < 32; shiftBy += 8 ) {
accum |= ( (long)( tmp[i] & 0xff ) ) << shiftBy;
i++;
return Float.intBitsToFloat(accum);
Not sure if i am missing some other way to do this... -
How to read *.pdf files and store them in a database?
Dear programmers,
I have problem with reading *.pdf files and store them in a database.
can any one help me, please!
Is it possible to read more than one file from the local system and store them in a database.
thnaks in advance.
byeWhat "problem" are you encountering?
Depending on your choice of database software, it may or may not support the storage of binary large objects (BLOBs). -
Open Photoshop 3 files and convert to TIFF or JPEG --- on the cheap!
Hello,
I have about a hundred large scans in PS3 format on DVD.
I never use PS or other pro photo SW; only iPhoto.
My last PS is v7.
I run the latest Snow Leopard on my new MBP 17 iCore7.
All I want is to recover these files and convert them to the highest quality and most accessible format without having to spend my $, only my time.
Can anyone put me near this goal?
---hI'm not sure what you mean by "PS3 format"--do you mean they are psd files that were created in Photoshop 3? As far as I remember Photoshop 3 simply created standard Photoshop files that, if one chose to have extensions (which you didn't have to way back then) had a .psd extension. If the files are indeed Photoshop files, but without the extension, you can simply copy them off the DVD and add the .psd extension to them. Preview will usually open psd files. I do have at least one VERY old psd file that Preview won't open, it displays a note in English and French, that Photoshop 3 is required. It does open with Photoshop Elements 8 and the free GIMP. Why it won't open in Preview I don't know, perhaps because it has three layers, two of which are text layers. Other psd files with layers DO open in Preview, although they often look a bit peculiar, and files with just one layer, created at the same time, open fine. Also, iPhoto will generally open psd files, and even display one with layers correctly (as if it had been flattened), but will not handle files with alpha channels very gracefully, nor will Preview. The GIMP has no problem with layers nor alpha channels.
Francine
Francine
Schwieder
Maybe you are looking for
-
How to change the capture resolution of CaptureDevice and toggle between front and rear camera
Hi. I'm using Visual Studio 2013, and the Windows Phone App template. I'm using the Microsoft.Devices / CaptureVideo API to capture video. I now want to set the resolution to capture the video in a specific(available) resolution. How do I do that? Co
-
How to make memory card as the default location fo...
Can I make the memory card as the default location for installion of Ovi apps? I have a Nokia C6-00 and if this is possible, anyone who can teach me do this thing? Thanks in advance. :-) "Always at the edge"
-
Keynote 09 Magic Move has a HUGE lag in slideshow mode
I LOVE magic move. My slides were amazing! Then the upgrade happened. And now magic move has a HUGE delay, sometimes even freezes the slideshow for 30 seconds at a time. Has anyone else experienced this? Has anyone figured out how to fix this?
-
'When I try to enter BofA or facebook or several other areas I get blocked out as if my security limit has been changed or something. I get these messages and follow the exception options and sometimes it works and other times it does not!
-
Libclntsh.so for 32 bits
I need to install the libclntsh.so dynamic library for 32 bits in a HP-UX linux 64 bits. Where I can find this library?