can anyone help me in my project. i need to convert the textfile contain binary into a color or pixels. I have the code but i cannot convert into a color or pixel. hopefully you can help me..
this is the code:
import java.awt.*; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; public class TEST1 extends Canvas { /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { // TODO code application logic here} try{ FileInputStream fstream = new FileInputStream("b.txt"); try (DataInputStream in = new DataInputStream(fstream)) { BufferedReader br = new BufferedReader(new InputStreamReader(in)); int[][] datafile; datafile=new int [40][40]; String strLine; String[] getvalue =new String [50]; int cols; int rows; cols=0; rows=0; while ((strLine = br.readLine()) != null) { //opensplite------------------------- String smartPhones = strLine; String[] smartPhonesSplits = smartPhones.split("\\,"); for(String smartPhone: smartPhonesSplits){ datafile[rows][cols]= Integer.parseInt(smartPhone); rows=rows+1; } //closesplite------------------------- rows=0; cols=cols+1; } // cols=0; for( cols=0;cols<=7;cols++){ for( rows=0;rows<=7;rows++){ if(datafile[rows][cols]==1){ System.out.print(color.class.getClasses()); } else{ System.out.print(" "); } } System.out.println(); } } }catch (IOException | NumberFormatException e){ System.err.println("Error: " + e.getMessage()); } } private static class color { public void color() { } public void color(Graphics g){ g.setColor(Color.blue); } } }