• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to insert a same size for all files in java?  RSS feed

 
barlet south
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am implementing a protocol in (java language) which perform over files . The protocol is working well but this protocol needs to be implemented for files which are the same size. Since the file i query from database are of different size is still any option too do all this files in the same size? I am thinking about padding but i am not sure if this will work in java. Let say we have four files one 5 MB another one 4 kB and another one 100 MB , i am thinking to put a default size of 500 MB for all filed meaning that these three files would be in the size of 500 MB all.
 
Paweł Baczyński
Bartender
Posts: 2074
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first question that comes to my mind is why do you need all files to be the same size?
The second would be are you really sure you need this?
Using 500MB to store a 4KB file is a big waste of disk space.
 
Carey Brown
Saloon Keeper
Posts: 3308
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Protocols for handling variable length data are usually handled by first transmitting the length and then transmitting the data. Padding is not a good idea.
 
barlet south
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paweł Baczyński

The reason behind this is that the protocol i am implemented query a file from database but in my case i have organised databased as a matrix which one row is one file. To query the data the rows must be the same size otherwise i cant query a row.

What i need to know is if is this possible to do it in java or not
 
Knute Snortum
Sheriff
Posts: 4270
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you ask, is it possible to do in Java, the answer is, Sure, you can do anything in Java. But you probably want to know how hard it will be.

To answer this, we need to understand the problem better. I still don't know why having a file in a database means you must have files all the same length. Variable length rows are very common in databases.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!