Click here to Skip to main content
15,908,674 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Kindly help me about this coding. Could any one update me back if any suggestions or improvements are required.


Using core java application to generate a QR(Quick Response) code based on a file which will contains characters. After generating code it should print the barcode image. The image size can also be parameterize.

The file will contain 6 fields, each field will have a 30 characters.

text format in file will be as follows

abcdefghijklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234abcdefghijklmnopqrstuvwxyz1234

in above text form a to 4 field one, again from a to 4 field 2 and so on.
Read the above text and generate QR code and images.


BarcodeReaderandImageGenerator.java
....................................
package barCodeReader.ImageGenerator;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import com.google.common.base.CharMatcher;
public class BarcodeReaderandImageGenerator {
public static void main(String[] args) throws IOException,FileNotFoundException {
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new FileReader("C:\\Users\\ICS-SYS1-USER1\\Desktop\\BAR CODE\\generatebarcode.txt"));
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
System.out.println("THE BAR CODE READ IS "+sb);
String BarcodeArray = sb.toString();
// String[] arr=BarcodeArray.split(" ");
// System.out.println("Array :"+arr.length);
//for(int i=0;i<arr.length;i++)>
//{
// System.out.println("array"+i+" :"+arr[i]);
//}
// Character[] c = ArrayUtils.toObject(BarcodeArray.toCharArray());
char counters[]=BarcodeArray.toCharArray();
int totalcharactercount =counters.length;
System.out.println("totalcharactercount = " + totalcharactercount);
int iterations = totalcharactercount/30;
System.out.println("total iterations = " + iterations);
if((totalcharactercount % 30)==0){
System.out.println("Bar Code Can Be Generated");
for(int i=0;i<counters.length;i++){>
System.out.println("BarCode at ["+i+"]="+counters[i]);

}
else{
System.out.println("Bar Code Cannot Be Generated");
}
// for (char counters = 'a'; counters <= '4'; counters ++) {
// System.out.println("Counter = " + counters);
// }

br.close();
}
}
Posted

 
Share this answer
 
try free open source zxing project[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900