• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to loop in a file which is converted to a byte of array?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I want to use secretShare method for each byte of the file . I know i need to use inside the body of this method something like :



but i do not where to start and finish this for loop . Can someone adjust my code with this for loop or if there exist any other way how to loop in byte array of file it will be also good.
 
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


but i do not where to start and finish this for loop . Can someone adjust my code with this for loop or if there exist any other way how to loop in byte array of file it will be also good.



I do not know what you are asking there. Do you want someone to match curly braces for you?
 
johnsoan smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes this is exactly what i want
 
Les Morgan
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johnsoan,

I am going to do you a favor and say: do it yourself. Spend a few minutes and create the proper indentation and track the braces. It is a simple exercise and if you are using an IDE, most IDE's will match braces for you with highlights.

Les

johnsoan smith wrote:Yes this is exactly what i want

 
johnsoan smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@LES Morgan apparently you did not understand what i wanted at all. So do not comment if you do not understand the problem . Is true that i want to know where to start and finish my curly braces but because i am working on a two dimensional array and my aim is to fix one column and iterate through rows .
 
Les Morgan
Rancher
Posts: 1093
29
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
johnsoan,

I asked in my first comment if you wanted someone to match your braces for you and your response was that it was exactly what you wanted, so please be more eloquent in your description of what you want because I have no idea, nor does anyone else, what it is--since you said that matching the braces is exactly what you want.

I asked:


I do not know what you are asking there. Do you want someone to match curly braces for you?


Your response was:


Yes this is exactly what i want



So be very specific now, what is it that you want?

Les

BTW: if you cannot fix your own curly braces, you need to NOT be using this code. You were already asked by the moderator to format your own code the last time you posted this question and to be more forthcoming in what it is that you actually want to know.

johnsoan smith wrote:@LES Morgan apparently you did not understand what i wanted at all. So do not comment if you do not understand the problem . Is true that i want to know where to start and finish my curly braces but because i am working on a two dimensional array and my aim is to fix one column and iterate through rows .

 
johnsoan smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@LES MORGAN look if you do not want to help me just do not reply here . I am stucked on sharing the file using this SSS algorithm . My file is not shared because when i implemented the code i fixed one row and then go through columns . Now my supervisor told me to do that for files so i need to adjust my code in order to fix one column and go through rows . And i did it by my own but my file was not still shared . I wanted to know where can be the problem ? To the for cycles or maybe is something that i have to do with files . I am telecommunication engineering and my background in java programming is not so strong. I do not know a lot about java I/O API and i am thinking maybe i am wasting time with for cycles and there is no error there and maybe there is something that needs to be done with file . If you really wanted to help me you just needed to take a look to the code and you as you think yourself as a clever guy will understand what is wrong to my code. As i know this is how this forum is working . To help each other .If you dont just dont write because i am offended by your second comment.
 
Saloon Keeper
Posts: 15510
363
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you're confusing a few things here, Johnsoan.

This forum is not here to present you with cut and clear solutions. We're here to help you figure out the solution for yourself. However, we can only do that if the problem is clear. Les Morgan asked you for clarification because he wanted to help you out, but so far it's still not clear and he's pointing that out.

A person also can't look at that code and understand what's wrong, because they don't know what you're trying to achieve in the first place. You say you have a problem with for-loops, and you say you don't have a lot of experience with I/O API, but the two are unrelated. You're not working with I/O, you're working with a byte array.

Now clearly, explain to us what the exact problem is you're facing, because we're not gonna be able to read it from your code.
 
johnsoan smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To be clear the problem is i want to fix one column and go through rows

I have one 2D array like this

share [] [] = new share [shares][m+1]

when int m= secret.length and where byte [] secret = one.readFile ()
so m has the size of my size in bytes
Now when i go through columns of 2D array and each column represent one byte of my file so let say if file text is hello column one represent h , second column represent e and so on

The rows represent shares which mean if i put to main as value of shares as 7 we will have 7 rows. Now what i want to do is something like that

for (byte coeff: secret ) { // so now i know i am fixing rows

for (int j=0 ; j<shares; j++ ) { // now i am itereating through rows and my column is fixed

now what i want to do and i am not able to do is i want to fill each cell of 2D array

and i wanted to use share [j] [//here i do not hot what to put] = (byte) evaluate(share[j][0], a);

where (byte) evaluate(share[j][0], a); is the value of polynomial i want to put on each cell of 2D array and i want to fill it as i mentioned above by fixing columns and go through rows . Hope now to be clear of what i want . If someone can help me with that would be perfect .
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am afraid that is not clear; whether it would be clearer if I were wide awake, I do not know.
You start by showing a share[][] (that should be Share[][] because class names start with CapitalLetters). Then you tell us you are looking for its bytes as if it were a byte[][]. You cannot mix types in an array. Either Shares or bytes. Never half and half.

Please explain what you are trying to do in very simple small words so even I can understand it. That process of explanation may help you work out how to solve the problem for yourself; that is jocularly called rubber duck programming.
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jumping in at the deep end because I still find the description vague. Looks like you need a second index into your 2D array (array of arrays). You have

which doesn't give you an index. Would this answer your question:
 
johnsoan smith
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@ Carey Brown you saved me . This is what i really wanted .
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic