byte 1 « Development « Java I/O Q&A





1. Best Way to Write Bytes in the Middle of a File in Java    stackoverflow.com

What is the best way to write bytes in the middle of a file using Java?

2. How would you change a single byte in a file?    stackoverflow.com

What is the best way to change a single byte in a file using Java? I've implemented this in several ways. One uses all byte array manipulation, but this is highly ...

3. File to byte[] in Java    stackoverflow.com

What is the best way to convert a java.io.File to a byte[]?

4. How do I identify that I am at the last byte of a serialized Java object?    stackoverflow.com

Question What is (if there is any) terminating characters/byte sequences in serialized java objects? Background I'm working on a small self-education project where I would like to serialize java objects and write them to ...

5. 8192 bytes when creating file    stackoverflow.com

In my Java code I have function that gets file from the client in http request and converts that in to the file. I have this line there:

byte[] buffer = new ...

6. After reading in bytes from file, most are right except 1 is wrong and negative    stackoverflow.com

In Java, I just read a file into a ByteBuffer. When I started checking to make sure that the ByteBuffer contained the right bytes, I noticed that it had mostly the ...

7. Java: interspersing bytes and characters    stackoverflow.com

I have a piece of test equipment, from which I can read data using an InputStream, which intersperses bytes and characters (organized into lines), e.g.:

TEST1
TEST2
500
{500 binary bytes follows here}
TEST3
TEST4
600
{600 binary bytes ...

8. Byte order mark screws up file reading in Java    stackoverflow.com

I'm trying to read CSV files using Java. Some of the files may have a byte order mark in the beginning, but not all. When present, the byte order gets read ...

9. casting byte[] to user defined class in java    stackoverflow.com

i want to cast byte[] which i got from socket a class which I write it (Message). I tried

byte[] data=new btyte[100];
.
.
.
Message m=(Message)data;
but it did not work and give me error what should ...





10. using java.util.Scanner to read a file byte by byte    stackoverflow.com

I'm trying to read a one line file character by character using java.util.Scanner. However I'm getting this exception":

Exception in thread "main" java.util.InputMismatchException: For input string: "contents of my file"
   ...

11. Read last byte from file and truncate to size    stackoverflow.com

I have a huge set of files, to all of which there is (should be) a sentinel character (1 byte) appended to the end of file. How can I read the ...

12. Difference between read(byte[] b, int off, int len) and read(byte [] b)    stackoverflow.com

In our project sometimes when we use InputStream.read(byte[] b) method, there is some error.
When we use

byte[] b = new byte[1024];
int len = -1;
while ((len = io.read(b, 0, 1024)) != -1) ...

13. I/O why does a byte can represent a character?    stackoverflow.com

and i see the character are only ASCII then its not dynamic right? any explanation for this? other question, what is the difference between byte streams and character streams?

14. How to get amount of serialized bytes representing a Java object    stackoverflow.com

What syntax would I use to get the number of bytes representing a string and compare them to the number of bytes representing an ArrayList holding that string, for example? I am ...

15. Java, how to override some bytes in a file    stackoverflow.com

I ve created a file using Java.io.File/FileInputStream/FileOutputStream. Now suppose that I want to change the value of some bytes in the file (for instance from the byte 15 to 35) whitout ...

16. I want to convert an Object to a byte[] using serialization in Java    stackoverflow.com

Hello I have a class called table. table keeps track of remoteIP, remotePort, macAdd and avgRtt this is the general structure of it.

public class table implements java.io.Serializable{


 String remoteIP;
 int remotePort;
 String ...





17. Read a file with 2048 bytes    stackoverflow.com

Guys i have a file which has only one line. The file has no encoding it is a simple text file with single line. For every 2048 byte in a line , ...

18. Write and read byte[] from file    stackoverflow.com

I'm looking for something simple (no external lib preferably) to write and load a byte[] from a file. More or less something like [Python's pickle][1].

byte[] bytes = new byte[10];
ByteBuffer bbuf ...

19. Reading the first 10 bytes of a file in Java    stackoverflow.com

    for (String name : filenames) {   
FileInputStream in = new FileInputStream(input.readUTF());   
    int byteCounter = 0;   
  ...

20. How do I read file x bytes at a time ? in java    stackoverflow.com

I want to read a file into a String in Java, x chars at a time. Then I'll do something with string, and want to continue from where I left off. ...

21. Split a file in java    stackoverflow.com

Hey Guys, I want to get a file, split it into fragments and encode each fragment using a linear code. The problem is I do not know what to encode. Do I ...

22. How can I determine the number of bytes of each line of a file in java?    stackoverflow.com

I have a very big text file. I want to determine the number of bytes of each line and save it in another file.

23. How can I read a file as unsigned bytes in Java?    stackoverflow.com

How can I read a file to bytes in Java? It is important to note that all the bytes need to be positive, i.e. the negative range cannot be used. Can this be ...

24. How to read bytes from a file, whereas the result byte[] is exactly as long    stackoverflow.com

I want the result byte[] to be exactly as long as the file content. How to achieve that. I am thinking of ArrayList<Byte>, but it doe not seem to be efficient. Another way ...

25. 2 bytes increment in serialized size of a PB message in case of adding one boolean field?    stackoverflow.com

I am building PB messages containing 4 int32 fields. I wanted to add two more boolean fields to this message. I noticed that the size increased by 4 bytes for 2 ...

26. Java File Encryption missing bytes    stackoverflow.com

I'm trying to write a simple program to encrypt and decrypt files using the AES algortihm. The intention later is to use split the simple program into encryption and decrytion methods ...

27. Write x bytes with value y to a file in java    stackoverflow.com

I am trying to write to a file certain number of bytes lets say x bytes, with a value y. The problem is that i am doing it lots of time ...

28. Help regarding the process in reading bytes from a file java    stackoverflow.com

Code already-

FileInputStream fis = new FileInputStream(files[0]);
DataInputStream dis = new DataInputStream(new BufferedInputStream(fis));
I am up to the process of reading my archive format(see How do I truncate a java integer to fit/exand ...

29. How to download a certain byte of the file via http    stackoverflow.com

How to download first 125 bytes and 125 last byte file via HTTP protocol ?

30. required int but there is a problem and found zero bytes    stackoverflow.com

How to solve this?

    File f=new File("d:/tester.txt");
    long size=f.length();  // returns the size in bytes
    char buff[]=new char[size]; // line of ...

31. Byte based (de)serialization in Java?    stackoverflow.com

I want to try abusing Java classes as structures and for that I'm wondering if it is possible to serialize a byte array to a class and other way around. So if ...

32. How to read UTF-8 characters from the file as bytes?    stackoverflow.com

I am not able to read a UTF-8 characters from the file as bytes. the UTF-8 characters are displaying as questionmarak(?) while converting to character from the bytes. Below code snippet shows file ...

33. Java - Comparing bytes in files that have weird contents    stackoverflow.com

I have a database dump program that writes out flat files of a table in a very specific format. I now need to test this against our old program and confirm ...

34. Most elegant way to read a file and operating on lines as bytes    stackoverflow.com

I have a database dump file I need to operate on rawly. I need to read the file in, operating on it line by line, but I can't have the whole ...

35. java reading serialized objects selectively using byte    stackoverflow.com

I am trying to write a program which reads serialized objects selectively from a file given their byte offsets. I started by serializing three objects of same type in a file ...

37. String with null bytes    coderanch.com

IBM's MQSeries is being used in the following: MQMessage msg; int len = 5; String str = msg.readString(len); The underlying class for MQMessage is a byte[]. It creates ByteArrayOutputStreams to read from. What happens is str ends up with a value of null bytes and I get false with the following comparisons: str.equals(null) results in false str == null results in ...

38. URGENT - converting bytes to Strings    coderanch.com

Hi guys, this is very urgent so I'm hopping you can give me a hand!!I'm reading in data from a serial port and I need to change the format from what it is into a String. Anybody know how to do this?? I presume I'll have to use something like InputStreamReader but I don't know how to go about it. I ...

39. Character vs. Byte    coderanch.com

I have a very basic question and hope someone will give me details. My question is: What is the difference between Byte and Character? I am taking in terms of stream. How are they represented? If the data in a file is represented in bytes is it same as binary file? What is the relation between Binary file, data in byte ...

40. byte [ ] to StringBuffer    coderanch.com

I don't know what constraints you're talking about. If memory is an issue, you should realize that the StringBuffer and byte[] will already take up a large amount of memory, roughly equal to that used by the String. (More specifically, the StringBuffer will require at least as much memory as the String, and the byte[] will take at least half as ...

41. how to compare a byte    coderanch.com

I am trying to read a byte stream and in particular trying to know if I have encountered #04-1 byte and #2A another byte.. below is the code... I am having trouble at if((previous=="#04")&&(current=="#2A")), how do I compare the value that I have in "previous" with that of "current"? thanks in advance I have a DataInputStream dis; boolean status=false; n = ...

42. Help me of Byte in Java    coderanch.com

43. interrupting System.in.read(byte[ ])    coderanch.com

Assume I have the following blocking I/O call in a thread: byte b[] = new byte[255]; try { System.in.read(b); } catch(IOException _ex) {} If I want to immediately unblock the I/O call from the main thread after a timeout period with Thread.interrupt() how would I do it? It seems Thread.interrupt() does not unblock InputStream.read()! I tried closing the InputStream with System.in.close() ...

44. Writing byte to a particular location in a file header    coderanch.com

Ok I have a file with a header which I've read and know the exact location of the particular element that I want to read. What I want to do now is overwrite that particular element of the file with a byte representation of a String. How do i do this, and also without creating a new file, cause I'm using ...

45. Reading - writing less than a byte ...    coderanch.com

Hello, Is there a way to read/write less than a byte from/to a file? If I am not mistaken ASCII chars are one byte each. What I want to do is re-encode some of the chars with less than a byte - let's say 4 or 5 bits each. Again, when I read a file of the above type I want ...

46. Measuring Bytes Transferred    coderanch.com

hi does anybody have any idea on how to write java code that measures the number of bytes transferred in java programs? i am really trying to measure the amount of bytes being transferred when my mobile agents move from one location to another. could someone kindly point me in the right direction. many thanks in advance. mendoza

47. byte[]    coderanch.com

48. FilteInputStream and byte    coderanch.com

Hi, I was confused looking in the JavaDoc API and finding following method: read(byte[] b) : Reads up to b.length bytes of data from this input stream into an array of bytes. Now a byte in Java is signed (max value 0x80), so how can the FileInputStream read correctly a binary file where there are bytes having a value bigger than ...

50. Writing byte[ ] to a file    coderanch.com

Hello all, i am having problems. I am reading bytes from a queue(mq series) and trying to simply write the bytes out to a .dat file, it is creating the file but it is empty. I'm not to good at Java IO so I need help - what am i doing wrong?? thanks , here is the code: while(true) { MQMessage ...

51. when to use characters or bytes    coderanch.com

Can someone please help me understand this. I have read about this very much but I just need a practical understanding of it. From my understanding the java io can be broken into two main types: 1. classes that operate in bytes. 2. classes that operate in characters. I can never decdide when to use one or the other. Can someone ...

53. writing 4 byte little-endian long integers    coderanch.com

I have a file that is a series of records and subrecords. Each record has a 4 byte string (4 characters, 8 bits per char obviously) followed by a 12 byte long and each subrecord has a 4 byte string and 4 byte long, they use little-endian. I can read & write the strings fine and I can read in the ...

54. how do convert byte[ } to String?    coderanch.com

55. Is there anything smaller that the byte?    coderanch.com

Hi, I'm working with java NIO, which uses ByteBuffers to transport data across the wire. I was wondering if it would be possible to compress the bytes in the ByteBuffer, for instance by using the *GZIP* classes delivered with the JDK or if the outcome of a GZIP compression would be a byte (in this case I would have already what ...

56. Converting File to Bytes and reading it in loop    coderanch.com

Hi, I have somehow got stuck in this - ------------------------------------------------------------------- Each time I need to read only max 0f 100 bytes from a file and then need to convert bytes to String and do some processing. Then I want to read next 100 bytes. this needs to go on till EOF. ------------------------------------------------------------------- Thanks in Advance Sumit

57. convert int ---> byte[]    coderanch.com

58. write byte[] to file?    coderanch.com

Hi, I could write the byte[] to a file.But I want to have that with a particular extension. Like "tif". the code I wrote: File f=new File("c:/temp/od/test.tif"); FileOutputStream fout = new FileOutputStream(f); fout.write(b);//b is byte[] obtained.. fout.close(); return f; My question is: Is this the right way to specify the file extension?. I could open the file from ie,paint etc. But ...

59. problem in reading bytes    coderanch.com

hi friends ,How are you all My task is ..I am sending the file to the server from the client i want to send the file some parts of bytes ...That is suppose my file is 470 bytes i want to send with 100 100 100 100 like this i want to send it ..i have written the code but getting ...

60. new String(byte[])    coderanch.com

I pass a byte array to create a new String object. However, the byte representation of this new string is different from the one I pass it. One of the bytes in the passed byte array is 0x90 or 144. However, in the string object tat i retrieve, this byte is 63! Tx in adv Kejal [ February 23, 2005: Message ...

61. Converting byte[] into a string    coderanch.com

I have a byte[] and I am trying to check to see what data it contains. checkData(byte [] data) { if(data != null && data.length > 0) { String dataString = new String(data); System.out.println("data "+dataString); } } This snippet of code causes a error exception The code is called via a config so the error is not the actual error but ...

62. Byte[] transfer problems : (    coderanch.com

Hi All I have a bluetooth phone application and a PC server appliction where i'm sending a picture taken from the phone to the server via bluetooth, i'm sending the image as an byte[] using dataoutput stream n receiving in an input stream, this method only excutes for small images like less than 40kb, and gets stuck for larger sizes, i'm ...

63. how to split byte[] to smaller chunks    coderanch.com

public static void splitBytes(byte[] fileBytes) throws Exception { int offset = 0; int fileCounter = 0; while (offset < fileBytes.length) { byte[] outputBytes; if(fileBytes.length - offset < 500 ) { outputBytes = new byte[fileBytes.length - offset]; System.arraycopy(fileBytes, offset, outputBytes, 0, fileBytes.length - offset); saveFile(outputBytes , fileCounter++); break; } outputBytes = new byte[500]; System.arraycopy(fileBytes, offset, outputBytes, 0, 500); offset +=500 ; saveFile(outputBytes ...

64. intermittent reading data into a byte[ ]    coderanch.com

Hi Guys I'm trying to read a stream into a byte array using FileInputStream reads(byte[] ) etc public void readPgm(String fileName) { String line; StringTokenizer st; try { FileInputStream in = new FileInputStream(fileName); BufferedReader br = new BufferedReader(new InputStreamReader(in)); int count = 0; // read PGM image header // in.readLine(); line = br.readLine(); count += line.length(); // if not a 'PGM ...

65. Extra bytes being read into file.    coderanch.com

Well, the biggest problem by far is that call to println(). The ln is an old abbreviation for "line". Every time you call it, you're printing one character followed by a line terminator (which is either one or two bytes long, depending on your operating system). So your file is probably two or three times as big as it should be, ...

66. java io UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8 sequence    coderanch.com

Hello, I have two queries as follows: a) What is the difference between response content types text/pdf and application/pdf ? 2) In my application i am generating a xml.In the generated XML the encoding is alreadys specified as "UTF-8". Now using this xml, i want to generated a PDF.For generating this PDF i am using JasperReport's class net.sf.jasperreports.engine.data.JRXmlDataSource. The code snippet ...

67. how to get the bytes required to load a file in memory?    coderanch.com

I want to know, when i insert a 1 MB file (say an jpeg image), how much bytes memory uses to load this file? And how to calculate it? using file.length() it returns size of original file size (disk size). I would like to know actual size in memory. for example few image softwares shows you the disk space of image ...

68. reading files as bytes and sending them as bytes    coderanch.com

Well, this is an awfully generic question. If you're just wondering about how to transfer the raw contents of the files, then just avoid using Readers or Writers; use InputStreams and OutputStreams, and all your data will be transferred as the raw, unadulterated file contents. If you're asking how to open files, how to do networking, etc, well, you'll have to ...

70. byte[] to file    coderanch.com

71. byte conversion    coderanch.com

72. Not getting the bytes sent    coderanch.com

Hi Ranchers, This thing has been bugging me for the last couple of days and am not able to find the reason why ... Server Program :- import java.net.*; import java.io.IOException; import java.io.InputStream; public class Server { public void connection() throws IOException { ServerSocket serverSocket = null; Socket clientSocket = null; int count=0; try { serverSocket = new ServerSocket(4400); System.out.println("Listen to ...

73. 1 Character seems to be written as one byte    coderanch.com

All along it has been hammered into my head that in java, characters are Unicode and they occupy 2 bytes, but it seems as if FileWriter does not fully agree. So I tried something basic - I wrote the little program below to write a character and read it back. Based on the output of the "dir" command in Vista, it ...

74. reading byte and char    coderanch.com

Thanks for your reply, I did some code run. I found that after reding bytes directly through InputStream, I try stuffing this stream into BufferedReader and read chars, it works fine. However after reading through BufferedReader, if I try reading bytes back from InoutStream, it hangs. Donn know if there are synchronization issues here(though BufferedReader code looks very straight) Thus for ...

75. BufferedImage from byte[]    coderanch.com

You could use one of the BufferedImage constructors, then call its getWriteableRaster method, and then use one of its setPixel methods appropriately. Do you know how the bytes are arranged in the byte[]? Meaning, in which order the Red, Green, Blue and transparency values are arranged (assuming it has those), and the width and height of the image?

76. What is the meaning of file containing byte datas?    coderanch.com

Hi All, I have encountered this particular line saying "go for reader and writer when the file is having character datas and go for InputStream and OutputStream when the file contains byte datas" now my question is what is a byte data? do they want to say "byte code" or file containing numbers from -128 to +127(byte range). please help how ...

77. what is meant by saving an object's state to a sequence of bytes    coderanch.com

Hi Birla, "serializing" means that the raw bytes of an object's data (=the state of that object) are used to store that object's state for example to a database or file or to send it over a network and so on. Moreover the process of serialization and deserialization can be adapted to your needs. So a serialized form of an object ...

78. Confusion with Binary, Byte representations    coderanch.com

Hi, I got this code snippet from this Binary File Processing resource link. char oldValue = 000; char newValue = 0xFF; final int bufferSize = 4 * 1024; // 4kb buffer byte[] buffer = new byte[bufferSize] I am just confused with the "0x00" and "0xFF" stuffs. Why should we assign the char variables to hexadecimal representations? Hope you can help me. ...

79. EOF reached before promised bytes    coderanch.com

This is the exception in question: java.net.ProtocolException: EOF after reading only: '0' of: '85' promised bytes, out of which at least: '0' were already buffe red at weblogic.servlet.internal.PostInputStream.complain(PostInputStream.java:93) at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:179) at weblogic.servlet.internal.ServletInputStreamImpl$1.read(ServletInputStreamImpl.java:157) at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:222) at weblogic.servlet.internal.ServletRequestImpl$RequestParameters.mergePostParams(ServletRequestImpl.java:1791) I figure that ServletInputStream is reading the bytes from the stream. It first got the size of the stream. Created a buffer of that size. ...

80. Byte oriented versus Character oriented    coderanch.com

81. Byte -127 Question    coderanch.com

I am struggling to get a String representation of a 4 byte array that represents an Integer (written from DataOutputStream). It seems that whenever one of the bytes results in a -127 value (HEX 0X81), when I convert the byte array to a String using new String(byte[]), a subsequent call to String.getBytes() converts the value -127 to 63. I can share ...

82. Best approch to read files as Byte    coderanch.com

In our application we use 3rd party checksum digest lib that requited to give source file as a byte array or as a ByteBuffer. Source files can be very to 1Mb to ~1GB . Here what is the most efficient approach to read those files in to byte array or ByteBuffer ?

83. String bytes manipulation    coderanch.com

I'm new in Java, and I have just a little experience in String manipulation. This is a quick problem to solve if you are a Java expert or at least have a considerable experience in it, but if you are a newbie(like me) this is an extremelly hard operation. I not asking you to solve the problem for me, but if ...

84. Writing and reading a byte file, help    coderanch.com

I got a program where i create a byte file (.dat) containing a string. And i got another program where i want to reat the byte file to see the string. But when i run the read method i buggs and tells me that the source is not found. This is the method i use to create the file: public static ...

85. Unable to read entire block :202 bytes read;expected 512 bytes    coderanch.com

Hi, I have a big problem, and I am hoping for an easy solution or workaround. I am trying to read an excel file using POI 2.0 (used 1.5 also) , but I get the following error: java.lang.Exception: java.io.IOException: Unable to read entire block; 202 bytes read; expected 512 bytes at csmip.EvpnExcelParser.displayFromExcel(Unknown Source) at csmip.EvpnExcelParser.importExcel(Unknown Source) at _jsps._mds._evpn_excel_import_jsp._jspService(_evpn_excel_import_jsp.java:130) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at ...

86. read next byte    coderanch.com

hi, how tell count read next char(byte) from file? public void fileReadInputData() { Thread Pause1 = new Thread(); Pause1.start(); try { FileReader fr = new FileReader("TestData.txt"); BufferedReader br = new BufferedReader(fr); int count; do { count = fr.read(text); for (int i = 0; i < count; i++) System.out.print(text[i]); Pause1.sleep(500); if(text[0] == '[') { //System.out.print("["); } if(text[0] == '.') { //System.out.print("."); } ...

87. [Java NIO] MappedByteBuffer does not write all bytes    coderanch.com

I'm seeing some weird behavior with MappedByteBuffer. It only seems to write 1024 * n + 1 bytes ignoring the other bytes. This happens only on an AIX machine. The same code works fine in Windows. public static void main(String[] args) { try { File f = new File("/home/satish/test"); FileChannel fc = new RandomAccessFile(f, "rw").getChannel(); int size = new Integer(args[0]); StringBuilder ...

88. Byte and character oriented    coderanch.com

89. Short [] to Byte [] Coversion Query    coderanch.com

hello there, I am using some example code to try and implement some Matlab capabilities in Java. One of the methods involves the conversion of a short[] to byte[]. Here is the code from the example public ByteAndShort2(short[] array, boolean bigEndian) { short[] unsignedByteArray; int[] unsignedShortArray; shortArray = array; isBigEndian = bigEndian; int N = shortArray.length; unsignedShortArray = new int[N]; for ...

90. Reading the first 10 bytes of a file    coderanch.com

for (String name : filenames) { FileInputStream in = new FileInputStream(input.readUTF()); int byteCounter = 0; int rowCounter = 0; long bufferCounter = 0; byte[] b = new byte[8]; int read; //in.skip(10); //while((read = in.read()) != -1){ while((read = in.read(b, 0, 10)) != -1){ byteCounter ++; if (byteCounter != 1000){ if (rowCounter == 16){ System.out.println("\n"); rowCounter = 0; } System.out.print(Integer.toHexString(read) + "\t"); ...

91. Wrapper utility : should wrap byte[]? Is there a better way?    coderanch.com

Hi, I'm looking into resolving a problem I'm facing with streams, bytes, byte arrays. I would like to hear your opinion on the best practice to implement what I want. So the story follows. I've created a series of classes, with property accessors, and some internal behavior. What I intend to reach is a class that developers can instantiate, define some ...

92. Convert 3 byte UTF-8 Japanese character into into HTML Entity    coderanch.com

Hi, I have been looking around all over the place and haven't found a way to convert a UTF-8 String that contains Japanese character into HTML entities. For example I have the character: Which corresponds to a 3 Byte String with int values (227,129,130). How do I convert these three integers into one large integer that is used as the ...

93. Unsigned byte in Java ?    coderanch.com

I'm doing a communication with a printer , and now I need to write to the serialPort , but studying I saw that java only has signed bytes except for the char data type , how can I build a byte array and one of the elements to be an unsigned byte ? it has to be byte array because I ...

94. Download file from x to y bytes    coderanch.com

95. Size of a String in Bytes    coderanch.com

I am currently building an xml file using Java and sending it to a web service that I know nothing about. There is a field that is limited to 8000 bytes. I have a 1749 character String in this field. When I use getBytes("UTF-8").length it returns 1770 (Well below the 8000 byte limit). But this program on the other side keeps ...

96. downloaded file byte size problem    coderanch.com

hallo everyopne, i made an application which download a .docx attachment form a mail account using javamail, but the downloaded file byte size is a bit bigger than the original file so when i try to open it word teels me that the file is corrupted, but clicking ok ok ok... then the files open and its visible, and its how ...

97. covert from byte to string and back to byte    coderanch.com

Hi, I hope someone can help me. I am trying to read in some binary data from a file, change a few bits and then write the information back. I read the data into an array of bytes. I then find the byte I need and convert it into a String, so I can change specific bits. After manipulating the String ...

98. Data loss converting StringBuilder to byte[]?    coderanch.com

Is there data loss when transferring from StringBuilder to a byte array? I think so, because the music I'm trying to play sounds like crap when I play it. I send the audio file as a string. I receive it as a StringBuilder. I append to the StringBuilder until all the data gets to the client. Then, I convert the StringBuilder ...

99. Remove first three bytes in a file.    coderanch.com

Read the bytes from the file. Write all except the first three to a new file. Close both files. Delete the original file. Rename the new file. (Although if your actual goal was to parse an XML document while ignoring its BOM, it's a lot easier to just consume the first three bytes from the InputStream before you pass it to ...

100. Decompress (un-gzip) a byte[]?    java-forums.org

I'm getting a byte array from the interwebz. However, this information is GZIP compressed. Because I'm getting the info from the internet, I really don't want to save it and then read the information, so that rules out FileInputStream/GZIPInputStream. With the "Inflater" class, it says that to unzip a GZIP file, you need a "dummy byte", but it doesn't elaborate at ...