title: How to generate a unique identifier of a fixed length in Java?
body: <p>I am trying to generate a unique identifier of a fixed length such as the IDs that are generated by Megaupload for the uploaded files.</p>
  
  <p>For example:</p>
  
  <ul>
  <li>ALGYTAB5</li>
  <li>BCLD23A6</li>
  </ul>
  
  <p>In this example using from A-Z and 0-9 and with a fixed length of 8 the total different combinations are 2,821,109,907,456.</p>
  
  <p>What if one of the generated id is already taken. Those ids are going to be stored in a database and it shouldn't be used more than once.</p>
  
  <p>How can I achieve that in Java?</p>
  
  <p>Thank you.</p>