Search Results

Search found 874 results on 35 pages for 'scanner'.

Page 30/35 | < Previous Page | 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Visual Studio Database Professional GDR R2 takes a long time to serialize DBMDL file

    - by Nicolas Webb
    The amount of time it takes to completely serialize the DBMDL (to finish "Your project will be available after 10000 operations are completed) is becoming a hindrance to productivity. I've done what I can to optimize disk activity (excluding my personal TEMP folder from the virus scanner, along with my local source repository). Short of getting a SSD I'm not sure what else I can do along those lines. I believe it has something to do with how the project is organized. The finished DBMDL file is roughly 150MB. Others throughout our organization do not seem to have this issue. Anyone had to deal with this?

    Read the article

  • How do I trap the ENTER key in WM 6.1 using C++

    - by Rob King
    Hi,Our barcode scanner application is written in C++ eMbedded V 4.00 and works well on the Motorola MC50 WM5 where the ENTER key is interpreted as an IDOK. We are moving the app to the MC55 with WM6.1 and the ENTER key does not translate to an IDOK. I'm of the impression we will have to programatically trap the key entry (or the value passed on via DataWedge). I have made several attempts to implement either a HOTKEY or something via an Accelerator Table but have been unable to interpret the Microsoft on-line descriptions. If there is a simpler answer that would be good news. If not, a more specific example than the MS samples would be greatly appreciated. Thanks in advance.

    Read the article

  • On-the-fly lossless image compression

    - by geschema
    I have an embedded application where an image scanner sends out a stream of 16-bit pixels that are later assembled to a grayscale image. As I need to both save this data locally and forward it to a network interface, I'd like to compress the data stream to reduce the required storage space and network bandwidth. Is there a simple algorithm that I can use to losslessly compress the pixel data? I first thought of computing the difference between two consecutive pixels and then encoding this difference with a Huffman code. Unfortunately, the pixels are unsigned 16-bit quantities so the difference can be anywhere in the range -65535 .. +65535 which leads to potentially huge codeword lengths. If a few really long codewords occur in a row, I'll run into buffer overflow problems.

    Read the article

  • Java MVC - How to divide a done text game into MVC?

    - by Zopyrus
    Been sitting here for hours now trying to figure this out, so a bit sympathy for this large question. :) The Goal: I simply want to divide my done code into MVC (Model View Controller) parts. I have the game logics done and text based - the code works fine. The Problem: Well, I want to implement this code into MVC, but where do explain for the MODEL that it should use text-based? Because the VIEW is only for the layout (graphically) correct? I am having a REALLY hard time figuring out where to begin at all. Any pointers would be so nice! Here is my game logics code: import mind.*; import javax.swing.*; import java.util.*; import java.lang.*; import java.awt.*; public class Drive { String[] mellan; boolean gameEnd, checkempty, checkempty2, enemy, enemy2; String gr,rd,tom; int digits; public Drive() { // Gamepieces in textform gr="G"; rd="R"; tom=" "; mellan = new String[7]; String[] begin = {gr,gr,gr,tom,rd,rd,rd}; String[] end = {rd,rd,rd,tom,gr,gr,gr}; //input Scanner in = new Scanner(System.in); mellan=begin; gameEnd=false; while (gameEnd == false) { for(int i=0; i<mellan.length; i++) { System.out.print(mellan[i]); } System.out.print(" Choose 0-6: "); digits = in.nextInt(); move(); checkWin(); } } void move() { //BOOLEAN for gameruls!!! checkempty = digits<6 && mellan[digits+1]==tom; checkempty2 = digits>0 && mellan[digits-1]==tom; enemy = (mellan[digits]==gr && mellan[digits+1]==rd && mellan[digits+2]==tom); enemy2 = (mellan[digits]==rd && mellan[digits-1]==gr && mellan[digits-2]==tom); if(checkempty) { mellan[digits+1]=mellan[digits]; mellan[digits]=tom; } else if (checkempty2) { mellan[digits-1]=mellan[digits]; mellan[digits]=tom; } else if (enemy) { mellan[digits+2]=mellan[digits]; mellan[digits]=tom; } else if (enemy2) { mellan[digits-2]=mellan[digits]; mellan[digits]=tom; } } void checkWin() { String[] end = {rd,rd,rd,tom,gr,gr,gr}; for (int i=0; i<mellan.length; i++){ } if (Arrays.equals(mellan,end)) { for (int j=0; j<mellan.length; j++) { System.out.print(mellan[j]); } displayWin(); } } void displayWin() { gameEnd = true; System.out.println("\nNicely Done!"); return; } // Kör Drive! public static void main(String args[]) { new Drive(); } } Here is how I defined my DriveView thus far: (just trying to make one button to work) import mind.*; import javax.swing.*; import java.util.*; import java.lang.*; import java.awt.*; import java.awt.event.*; public class DriveView extends JFrame { JButton ruta1 = new JButton("Green"); JButton ruta2 = new JButton("Green"); JButton rutatom = new JButton(""); JButton ruta6 = new JButton("Red"); private DriveModel m_model; public DriveView(DriveModel model) { m_model = model; //Layout for View JPanel myPanel = new JPanel(); myPanel.setLayout(new FlowLayout()); myPanel.add(ruta1); myPanel.add(ruta2); myPanel.add(rutatom); myPanel.add(ruta6); this.setContentPane(myPanel); this.pack(); this.setTitle("Drive"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } void addMouseListener(ActionListener mol) { ruta2.addActionListener(mol); } } And DriveController which gives me error at compile import mind.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.lang.*; public class DriveController { private DriveModel m_model; private DriveView m_view; public DriveController(DriveModel model, DriveView view) { m_model = model; m_view = view; view.addMouseListener(new MouseListener()); } class MouseListener implements ActionListener { public void actionPerformed(ActionEvent e) { String mening; mening = e.getActionCommand(); if (mening.equals("Green")) { setForeground(Color.red); } } } }

    Read the article

  • Firefox add-on tab-specific buttons and scripts, similar to Page Actions in Google Chrome

    - by Chetan
    I want to write a Firefox extension that acts exactly like the built-in RSS feed scanner (as an exercise). It should do the following: On each new page / tab load, it should scan the content of the page for RSS feeds If there are RSS feeds in the page, it should put a button in the location bar that the user can click On clicking the button, a speech bubble should appear under the button (the way a speech bubble appears under the bookmarks star when you click on it), with information on the feeds and buttons to subscribe to them So my main questions are: What is the process to run specific content scripts for specific pages? What is the process to use the results of those scripts to update the speech bubble for each location bar button for each tab? Basically, I'm trying to figure out how to do in Firefox what Page Actions are in Google Chrome. Please help! :)

    Read the article

  • Guice + Quartz + iBatis

    - by DroidIn.net
    I'm trying to wire together Guice (Java), Quartz scheduler and iBatis (iBaGuice) to do the following: Start command line utility-scanner using main() Periodically scan directory (provided as argument) for files containing formatted output (XML or YAML) When file is detected, parse and output result to the database The problems: I used this example to wire Guice and Quartz. However I'm missing some important details which I'm asking in the comments but the post is somewhat dated so I'm quoting it here also: It's not obvious how to set-up the scheduler. Where and how would I wire the Trigger (I can use Trigger#makeMinutelyTrigger)? I really have just one type of job I will be executing, I understand that details in the JobFactory#newJob are coming from the TriggerFiredBundle parameter but where/how do I wire that? And where/how do I create or wire concrete Job?

    Read the article

  • Monotouch Binding to Linea Pro SDK

    - by jeffrapp
    I'm trying to create a binding to the Linea Pro (it's the barcode scanner they use in the Apple Stores, Lowes) SDK. I'm using David Sandor's bindings as a reference, but the SDK has been updated a few times since January of 2011. I have most everything working, except for the playSound call, which is used to, well, play a sound on the Linea Pro device. The .h file from the SDK has the call as follows: -(BOOL)playSound:(int)volume beepData:(int *)data length:(int)length error:(NSError **)error; I've tried using int[], NSArray, and an IntPtr to the int[], but nothing seems to work. The last unsuccessful iteration of my binding looks like: [Export ("playSound:beepData:length:")] void PlaySound (int volume, NSArray data, int length); Now, this doesn't work at all. Also note that I have no idea what to do with the error:(NSError **)error part, either. I am lacking some serious familiarity with C, so any help would be extremely appreciated.

    Read the article

  • Counting the number of characters in a file

    - by Kat
    I'm writing a program that for one part asks for the program to print how many characters (including whitespaces) are in a file. The code I have right now though returns 0 every time though and I'm not sure why it isn't counting the characters. public int getcharCount(Scanner textFile) { int count = 0; while(textFile.hasNext()) { String line = textFile.nextLine(); for(int i=0; i < line.length(); i++) count++; } return count; }

    Read the article

  • Prevent users from being able to access a webpage via web browser?

    - by Rob
    My friend and I are working on a program. This program is going to submit GET data to our webpage. However, we don't want users accessing the webpage any other way than the program. We can prevent users from sharing the program using HWID authentication, but nothing prevents them from using a packet scanner to get the URL of the webpage. We thought about user-agent authentication, which we will implement, but user-agents can easily be spoofed. So my question is, how can we prevent users from accessing the webpage directly, instead of through the program? Even if you don't have an answer that will completely work, anything that will help deter them would be nice. Currently we will be implementing: HWID Authentication to use the program User-Agent Authentication to access the web page Instant IP Blacklisting to anyone accessing the webpage without the proper User-Agent

    Read the article

  • StructureMap: Wiring (generic) implementations to an implementation of another type

    - by Jeremy Frey
    If I have an interface: public interface IRepository<T> And an abstract class: public abstract class LinqToSqlRepository<T, TContext> : IRepository<T> where T : class where TContext : DataContext And a whole bunch of implementations of IRepository / LinqToSqlRepository (e.g. AccountRepository, ContactRepository, etc.), what's the best way to to use StructureMap (2.5.3) to generically wire them all up? e.g., I want this code to pass: [Test] public void ShouldWireUpAccountRepositories { var accountRepo = ObjectFactory.GetInstance<IRepository<Account>>(); Assert.IsInstanceOf<AccountRepository>(accountRepo); } Without explicitly writing this: ObjectFactory.Configure(x => x.ForRequestedType<IRepository<Account>>() .TheDefaultIsConcreteType<AccountRepository>()); In the past, we've always created a specific interface on each repository that inherited from the generic one, and used the default scanner to automatically wire all of those instances, but I'd like to be able to ask specifically for an IRepository<Account> without cluttering up the project with additional interfaces / configurations.

    Read the article

  • How do I avoid symlinks using an Ant FileSet?

    - by Will
    I have a directory tree that includes a symlink to . (the current directory). When I attempt to iterate over this using an Ant FileSet, I get the following error: Caught error while checking for symbolic links at org.apache.tools.ant.DirectoryScanner.causesIllegalSymlinkLoop(DirectoryScanner.java:1859) The code that I am using to generate the scanner is: FileSet files = new FileSet(); Project project = new Project(); project.setBasedir( dir ); files.setProject( project ); files.setDir( project.getBaseDir() ); files.getDirectoryScanner().setFollowSymlinks( false ); for( Iterator iter = files.iterator(); iter.hasNext(); ) {}

    Read the article

  • How would I access the Windows Login (Authentication) API from a C++ Service Application?

    - by Gabriel
    Let us imagine for a moment that I have a piece of hardware that can act as an authentication for a user on a given system. I want to write an application in C++ to run as a service, look for this device and if found log the appropriate user in. I believe I have found the API's I would need to use to perform the hardware and service portions of the application but am having a hard time nailing down a way to create a "real" user login. Is this possible? If so where would I look to find resources on accomplishing this? I think of it as being an analog to fingerprint scanner login type devices.

    Read the article

  • COM port - how to identify a device (.net/c#)

    - by argh
    Hi, I'm programming for Windows CE and I need to connect to a scanner. There is no problem - I know that it is on port COM0, but if I plug in another device earlier it gets another COM port... to get all com ports the easy way is: SerialPort.GetPortNames() But I don't know how to identify a device? Is there any standard way? I can't 'ping' it since there is one device that only sends data... it spams data all the time... and I don't know how to 'ping' a device...

    Read the article

  • Why does DataInputStream not support integers?

    - by Jason
    I need to read in a list of numbers from a file, none of which are larger than 32767. Originally I was going to use the Scanner class to pull in the data, then I read about DataInputStream. This would work well for me, except that according to the API, it supports all primitive variables EXCEPT ints! Listed are longs, shorts, bytes, chars, booleans, ect, but no ints. I have no need for double precision from the incoming data. Is this a deliberate or unintentional oversight?

    Read the article

  • Ad hoc network between iPhone and non iPhone devices???

    - by gn-mithun
    Is it possible to set up a ad hoc network between an iPhone and a totally different device like camera,scanner or printer and build a data tunnel between them to exchange data or services. I believe iPhone does not have the provision of creating an ad hoc network. So i am assuming that the other device are the initiator of the ad hoc network. I tried doing the same with a mac book and iPhone and i could surf on the phone after enabling internet sharing. But i wanted to make sure that its possible with other devices as well I believe the upcoming WiFi Direct is a way to do it.

    Read the article

  • Multi-process builds in Visual Studio 2010: Worth it?

    - by coryr
    I've started testing our C++ software with VS2010 and the build times are really bad (30-45 minutes, about double the VS2005 times). I've been reading about the /MP switch for multi-process compilation. Unfortunately, it is incompatible with some features that we use quite a bit like #import, incremental compilation, and precompiled headers. Have you had a similar project where you tried the /MP switch after turning off things like precompiled headers? Did you get faster builds? My machine is running 64-bit Windows 7 on a 4 core machine with 4 GB of RAM and a fast SSD storage. Virus scanner disabled and a pretty minimal software environment.

    Read the article

  • Https in java ends up with strange results

    - by Senne
    I'm trying to illustrate to students how https is used in java. But i have the feeling my example is not really the best out there... The code works well on my windows 7: I start the server, go to https://localhost:8080/somefile.txt and i get asked to trust the certificate, and all goes well. When I try over http (before or after accepting the certificate) I just get a blank page, which is ok for me. BUT when I try the exact same thing on my windows XP: Same thing, all goes well. But then (after accepting the certificate first), I'm also able to get all the the files through http! (if I first try http before https followed by accepting the certificate, I get no answer..) I tried refreshing, hard refreshing a million times but this should not be working, right? Is there something wrong in my code? I'm not sure if I use the right approach to implement https here... package Security; import java.io.*; import java.net.*; import java.util.*; import java.util.concurrent.Executors; import java.security.*; import javax.net.ssl.*; import com.sun.net.httpserver.*; public class HTTPSServer { public static void main(String[] args) throws IOException { InetSocketAddress addr = new InetSocketAddress(8080); HttpsServer server = HttpsServer.create(addr, 0); try { System.out.println("\nInitializing context ...\n"); KeyStore ks = KeyStore.getInstance("JKS"); char[] password = "vwpolo".toCharArray(); ks.load(new FileInputStream("myKeys"), password); KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, password); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(kmf.getKeyManagers(), null, null); // a HTTPS server must have a configurator for the SSL connections. server.setHttpsConfigurator (new HttpsConfigurator(sslContext) { // override configure to change default configuration. public void configure (HttpsParameters params) { try { // get SSL context for this configurator SSLContext c = getSSLContext(); // get the default settings for this SSL context SSLParameters sslparams = c.getDefaultSSLParameters(); // set parameters for the HTTPS connection. params.setNeedClientAuth(true); params.setSSLParameters(sslparams); System.out.println("SSL context created ...\n"); } catch(Exception e2) { System.out.println("Invalid parameter ...\n"); e2.printStackTrace(); } } }); } catch(Exception e1) { e1.printStackTrace(); } server.createContext("/", new MyHandler1()); server.setExecutor(Executors.newCachedThreadPool()); server.start(); System.out.println("Server is listening on port 8080 ...\n"); } } class MyHandler implements HttpHandler { public void handle(HttpExchange exchange) throws IOException { String requestMethod = exchange.getRequestMethod(); if (requestMethod.equalsIgnoreCase("GET")) { Headers responseHeaders = exchange.getResponseHeaders(); responseHeaders.set("Content-Type", "text/plain"); exchange.sendResponseHeaders(200, 0); OutputStream responseBody = exchange.getResponseBody(); String response = "HTTP headers included in your request:\n\n"; responseBody.write(response.getBytes()); Headers requestHeaders = exchange.getRequestHeaders(); Set<String> keySet = requestHeaders.keySet(); Iterator<String> iter = keySet.iterator(); while (iter.hasNext()) { String key = iter.next(); List values = requestHeaders.get(key); response = key + " = " + values.toString() + "\n"; responseBody.write(response.getBytes()); System.out.print(response); } response = "\nHTTP request body: "; responseBody.write(response.getBytes()); InputStream requestBody = exchange.getRequestBody(); byte[] buffer = new byte[256]; if(requestBody.read(buffer) > 0) { responseBody.write(buffer); } else { responseBody.write("empty.".getBytes()); } URI requestURI = exchange.getRequestURI(); String file = requestURI.getPath().substring(1); response = "\n\nFile requested = " + file + "\n\n"; responseBody.write(response.getBytes()); responseBody.flush(); System.out.print(response); Scanner source = new Scanner(new File(file)); String text; while (source.hasNext()) { text = source.nextLine() + "\n"; responseBody.write(text.getBytes()); } source.close(); responseBody.close(); exchange.close(); } } }

    Read the article

  • what kind of credentials/prerequisites do you need to be a professional penetration tester ?

    - by dfafa
    does it take more than knowing Bt4 ? are there any one that just runs a scanner and no real labor involved ? would you be expected to be able to code your own exploits without having to dl from milw0rm and discover entry into a system by yourself, in other words, do you have to think outside the box even when there's so many tools that makes the job a lot easier ? would you ever be expected to be able to write your own scanners, exploits and etc ? i am also curious how people are able to write long pages of hex address, that magically causes some type of memory overflow...how are people guessing at the hex values for game hacks for instance ? are certification important ? what about formal school education ? I am a CS major.

    Read the article

  • How to implement file transfer with Java sockets?

    - by ZeKoU
    Hello, I am working on a chat implementation with Java sockets. I have focused on few functionalities, like authentication, one person chat and a group chat. I was thinking about adding file transfer functionality, and I wonder what's the good practice about this. Should I have separate socket on the server with different port listening just for file transfers? Right now input and output streams that I get from server socket are binded to Scanner and PrintWriter objects respectively, so I find it hard to use that for file transfer. Any patterns you guys could recommend or give me good recommendations are very appreciated. Thanks, ZeKoU

    Read the article

  • Known problems with filemtime() on Windows - files getting touched arbitrarily?

    - by Pekka
    Is there a known issue leading to file modification times of cache files on Windows XP SP 3 getting arbitrarily updated, but without any actual change? Is there some service on a standard Windows XP - Backup, Sync, Versioning, Virus scanner - known to touch files? They all have a .txt extension. If there isn't, forget it. Then I'm getting something wrong in my cache routines, and I'll debug my way through. Background: I'm building a simple caching wrapper around a slow web site on a Windows server. I am comparing the filemtime() time stamp to some columns in the data base to determine whether a cached file is stale. I'm having problems using this method because the modification time of the cache files seems to get updated in between operations without me doing anything. THis results in stale files being displayed. I'm the only user on the machine. The operating system is Windows XP, the webserver a XAMPP Apache 2 with PHP 5.2

    Read the article

  • spring mvc forward to jsp

    - by jerluc
    I currently have my web.xml configured to catch 404s and send them to my spring controller which will perform a search given the original URL request. The functionality is all there as far as the catch and search go, however the trouble begins to arise when I try to return a view. <bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver" p:order="1"> <property name="mediaTypes"> <map> <entry key="json" value="application/json" /> <entry key="jsp" value="text/html" /> </map> </property> <property name="defaultContentType" value="application/json" /> <property name="favorPathExtension" value="true" /> <property name="viewResolvers"> <list> <bean class="org.springframework.web.servlet.view.BeanNameViewResolver" /> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/" /> <property name="suffix" value="" /> </bean> </list> </property> <property name="defaultViews"> <list> <bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" /> </list> </property> <property name="ignoreAcceptHeader" value="true" /> </bean> This is a snippet from my MVC config file. The problem lies in resolving the view's path to the /WEB-INF/jsp/ directory. Using a logger in my JBoss setup, I can see that when I test this search controller by going to a non-existent page, the following occurs: Server can't find the request Request is sent to 404 error page (in this case my search controller) Search controller performs search Search controller returns view name (for this illustration, we'll assume test.jsp is returned) Based off of server logger, I can see that org.springframework.web.servlet.view.JstlView is initialized once my search controller returns the view name (so I can assume it is being picked up correctly by the InternalResourceViewResolver) Server attempts to return content to browser resulting in a 404! A couple things confuse me about this: I'm not 100% sure why this isn't resolving when test.jsp clearly exists under the /WEB-INF/jsp/ directory. Even if there was some other problem, why would this result in a 404? Shouldn't a 404 error page that results in another 404 theoretically create an infinite loop? Thanks for any help or pointers! Controller class [incomplete]: @Controller public class SiteMapController { //-------------------------------------------------------------------------------------- @Autowired(required=true) private SearchService search; @Autowired(required=true) private CatalogService catalog; //-------------------------------------------------------------------------------------- @RequestMapping(value = "/sitemap", method = RequestMethod.GET) public String sitemap (HttpServletRequest request, HttpServletResponse response) { String forwardPath = ""; try { long startTime = System.nanoTime() / 1000000; String pathQuery = (String) request.getAttribute("javax.servlet.error.request_uri"); Scanner pathScanner = new Scanner(pathQuery).useDelimiter("\\/"); String context = pathScanner.next(); List<ProductLightDTO> results = new ArrayList<ProductLightDTO>(); StringBuilder query = new StringBuilder(); String currentValue; while (pathScanner.hasNext()) { currentValue = pathScanner.next().toLowerCase(); System.out.println(currentValue); if (query.length() > 0) query.append(" AND "); if (currentValue.contains("-")) { query.append("\""); query.append(currentValue.replace("-", " ")); query.append("\""); } else { query.append(currentValue + "*"); } } //results.addAll(this.doSearch(query.toString())); System.out.println("Request: " + pathQuery); System.out.println("Built Query:" + query.toString()); //System.out.println("Result size: " + results.size()); long totalTime = (System.nanoTime() / 1000000) - startTime; System.out.println("Total TTP: " + totalTime + "ms"); if (results == null || results.size() == 0) { forwardPath = "home.jsp"; } else if (results.size() == 1) { forwardPath = "product.jsp"; } else { forwardPath = "category.jsp"; } } catch (Exception ex) { System.err.println(ex); } System.out.println("Returning view: " + forwardPath); return forwardPath; } }

    Read the article

  • Error showing is NullPointerException [duplicate]

    - by user3659612
    This question already has an answer here: How to check a string against null in java? 11 answers I was trying to code a wifi scanner which does 20 scans but it shows NullPointerException at if(bssid[j].equals(null)){ My code is slightly huge package com.example.scanner; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.wifi.ScanResult; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Environment; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.ListView; import android.widget.Toast; public class MainActivity extends ActionBarActivity { WifiManager wifi; WifiScanReceiver wifireciever; WifiInfo info; Button scan, save; List<ScanResult> wifilist; ListView list; String wifis[]; String name; String[] ssid = new String[100]; String[] bssid = new String[100]; int[] lvl = new int[100]; int[] count = new int[100]; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fragment_main); list=(ListView)findViewById(R.id.listView1); scan=(Button)findViewById(R.id.button1); save=(Button)findViewById(R.id.button2); scan.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub wifi=(WifiManager)getSystemService(Context.WIFI_SERVICE); if (wifi.isWifiEnabled()==false){ wifi.setWifiEnabled(true); } wifireciever = new WifiScanReceiver(); for (int i=0;i<20;i++){ registerReceiver(wifireciever, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); wifi.startScan(); if (i==19){ Toast.makeText(getBaseContext(), "Scan Finish", Toast.LENGTH_LONG).show(); } } } }); save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub savedata(); } }); } protected void savedata() { // TODO Auto-generated method stub try { File sdcard = Environment.getExternalStorageDirectory(); File directory = new File(sdcard.getAbsolutePath() + "/WIFI_RESULT"); directory.mkdirs(); name = new SimpleDateFormat("yyyy-MM-dd HH mm ss").format(new Date()); File file = new File(directory,name + "wifi_data.txt"); FileOutputStream fou = new FileOutputStream(file); OutputStreamWriter osw = new OutputStreamWriter(fou); try { for (int i =0; i < list.getCount(); i++){ osw.append(list.getItemAtPosition(i).toString()); } osw.flush(); osw.close(); Toast.makeText(getBaseContext(), "Saved", Toast.LENGTH_LONG).show(); } catch (IOException e){ e.printStackTrace(); } } catch (FileNotFoundException e){ e.printStackTrace(); } } class WifiScanReceiver extends BroadcastReceiver { @SuppressLint("UseValueOf") public void onReceive(Context c, Intent intent) { int a =0; wifi.startScan(); List<ScanResult> wifilist = wifi.getScanResults(); if (a<wifilist.size()){ a=wifilist.size(); } for(int j=0;j<wifilist.size();j++){ if(bssid[j].equals(null)){ ssid[j] = wifilist.get(j).SSID.toString(); bssid[j] = wifilist.get(j).BSSID.toString(); lvl[j] = wifilist.get(j).level; count[j]++; } else if (bssid[j].equals(wifilist.get(j).BSSID.toString())){ lvl[j] = lvl[j] + wifilist.get(j).level; count[j]++; } } wifis = new String[a]; for (int i =0; i<a; i++){ wifis[i] = ("\n" + ssid[i] + "\n AP Address" + bssid[i] + "\n Signal Strength:" + lvl[i]/count[i]).toString(); } list.setAdapter(new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,wifis)); } } protected void onDestroy() { unregisterReceiver(wifireciever); super.onPause(); } protected void onResume() { registerReceiver(wifireciever, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); super.onResume(); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.main, menu); return true; } } NullPointerException at that point mean my array bssid isn't initialize. So I just want to know how to initialize it in main activity so that I can use that string bssid anywhere.

    Read the article

  • Java Program Compiles and Runs, but doesn't work

    - by Richard Long
    When I run this program I enter information in a text box, push the search button, but nothing happens. The program just sits there until I press Cntrl C to break it. It looks like it should work, but I can't figure out what is hanging the program up. Here is the code: First class: import java.io.*; import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.util.*; public class NameGameFrame extends JFrame { public static String name; static JTextField textfield = new JTextField(20); static JTextArea textarea = new JTextArea(30,30); public static String num; public static String [] fields; public static int [] yearRank; public static boolean match; public static int getInts, marker, year, max; public static void main( String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("Name Game"); frame.setLocation(500,400); frame.setSize(800,800); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); JLabel label = new JLabel("Enter the Name or Partial Name to search:"); c.gridx = 0; c.gridy = 0; c.insets = new Insets(2,2,2,2); panel.add(label,c); c.gridx = 0; c.gridy = 1; panel.add(textarea,c); JButton button = new JButton("Search"); c.gridx = 1; c.gridy = 1; panel.add(button,c); c.gridx = 1; c.gridy = 0; panel.add(textfield,c); frame.getContentPane().add(panel, BorderLayout.NORTH); frame.pack(); frame.setVisible(true); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { name = textfield.getText(); java.io.File file = new java.io.File("namesdata.txt"); try { Scanner input = new Scanner(file); num = input.nextLine(); NameRecord nr = new NameRecord(name); while (input.hasNext()) { if(match = num.toLowerCase().contains(name.toLowerCase())) { nr.getRank(); nr.getBestYear(marker); } } } catch(FileNotFoundException e) { System.err.format("File does not exist\n"); } textarea.setText(fields[0]); } }); } } This is the second class: import java.io.*; import java.util.*; public class NameRecord { public NameRecord( String name) { } public static int getBestYear(int marker) { switch (marker) { case 1: year = 1900; break; case 2: year = 1910; break; case 3: year = 1920; break; case 4: year = 1930; break; case 5: year = 1940; break; case 6: year = 1950; break; case 7: year = 1960; break; case 8: year = 1970; break; case 9: year = 1980; break; case 10: year = 1990; break; case 11: year = 2000; break; } return year; } public static int getRank() { fields = num.split(" "); max = 0; for (int i = 1; i<12; i++) { getInts = Integer.parseInt(fields[i]); if(getInts>max) { max = getInts; marker = i; } } return max; } }

    Read the article

  • help with installing clamav for remote apache server vs WAMP localserver

    - by Scarface
    Hey guys, I have never installed an extension before so I am not really sure where to start. I want to do 2 things: install clamav virus scanner http://sourceforge.net/projects/php-clamav/ on my remote server which is a linux apache setup using cpanel as a gui. install clamav on my localserver on my home computer which operates on windows and has WAMP server installed for server-side activity What is the difference between the two installation methods? What is required for each installation? If anyone can point me in the right direction in any way, I would really appreciate it. Even if it is just an article or tutorial on how to get started.

    Read the article

  • "input cannot be resolved" when added a try..catch

    - by Mark
    I originally tried to get my throw statement to work without a try catch and the userInput = input.nextInt(); line worked fine. But when I tried adding the try..catch it didn't like my input saying it cannot be resolved. I don't think my try..catch is correct yet but I am planning on tackling that after I can get this input to be recognized but I would appreciate any feedback on things you see with that as well. Thanks import java.util.Scanner; public class Program6 { public static void main(String[] args) { final int NUMBER_HIGH_LIMIT = 100; final int NUMBER_LOW_LIMIT = 10; int userInput; try { System.out.print("Enter a number between 10 and 100: "); userInput = input.nextInt();//Says input cannot be resolved Verify v = new Verify(NUMBER_HIGH_LIMIT, NUMBER_LOW_LIMIT); } catch(NumberHighException exception) { userInput = 0; } catch(NumberLowException exception) { userInput = 0; } } }

    Read the article

< Previous Page | 26 27 28 29 30 31 32 33 34 35  | Next Page >