hi i have been able to detect bluetooth device and send the bluetooth device a specific message. Now i want it to permantly do these tasks, that is for every 1 minute the code is executed again and again . Please help me out and its vvvvvvvvvvvvvvvvvvvvvvvvv urgent for my final year project. Thanks in advance. my code are as follows:
//System.out.println("putting...."); Operation po = cs.put(hs);
printString("___________________________________________________________________________"); System.out.println("***Sent text message successfully...***"); printString("___________________________________________________________________________"); po.openOutputStream().write(text); po.close(); cs.disconnect(null); cs.close();
System.out.println("***closed...***"); printString("___________________________________________________________________________"); // Approve (Open or Save) was clicked break;
case JFileChooser.CANCEL_OPTION: // Cancel or the close-dialog icon was clicked break;
case JFileChooser.ERROR_OPTION: // The selection process did not complete successfully break; } }
catch (Throwable e) { e.printStackTrace(); } }
// Returns the contents of the file in a byte array. public static byte[] getBytesFromFile(File file) throws IOException { InputStream is = new FileInputStream(file);
// Get the size of the file long length = file.length();
// You cannot create an array using a long type. // It needs to be an int type. // Before converting to an int type, check // to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE) { System.out.println("File is too large\n"); // File is too large }
// Create the byte array to hold the data byte[] bytes = new byte[(int)length];
// Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) { offset += numRead; }
// Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file "+file.getName()); }
// Close the input stream and return bytes is.close(); return bytes; }
class TxtMyFilter extends javax.swing.filechooser.FileFilter { public boolean accept(File file) { String filename = file.getName(); return filename.endsWith(".txt"); }
public String getDescription() { return "*.txt"; } }
This reads very much like a duplicate. In which case I'm going to close this one. Please continue any discusion in your other post. [ January 08, 2007: Message edited by: Paul Sturrock ]