Search Results

Search found 2500 results on 100 pages for 'util'.

Page 6/100 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • math.Random isn't working right

    - by RandomlyKnighted
    I'm trying to simulate a coin flip using the code below. public class Coin { public static double result; int[] count = new count[2]; public static void flip() { result = Math.random(); } public static boolean isHeads() { if (result == 0.0) { count[0]++; return false; } else { count[1]++; return true; } } public static void main(String[] args) { flip(); isHeads(); System.out.println(count[0]); System.out.println(count[1]); } } For some reason Eclipse says that the import java.util.Random; is never used even though I'm clearly using it. I didn't put my for loop into the code above but it loops n number of times and then outputs the result. No matter how many times it loops it always returns that the result is greater than 0.0 which can't be right. Am I calling Math.random incorrectly?

    Read the article

  • Objective-C: How to access methods in other classes

    - by Adam
    I have what I know is a simple question, but after many searches in books and on the Internet, I can't seem to come up with a solution. I have a standard iPhone project that contains, among other things, a ViewController. My app works just fine at this point. I now want to create a generic class (extending NSObject) that will have some basic utility methods. Let's call this class Util.m (along with the associated .h file). I create the Util class (and .h file) in my project, and now I want to access the methods contained in that class class from my ViewController. Here's an example of a simple version of Util.h #import <Foundation/Foundation.h> @interface Util : NSObject { } - (void)myMethod; @end Then the Util.m file would look something like this: #import "Util.h" @implementation Util - (void)myMethod { NSLog(@"myMethod Called"); } @end Now that my Util class is created, I want to call the "myMethod" method from my ViewController. In my ViewController's .h file, I do the following: #import "Util.h" @interface MyViewController : UIViewController { Util *utils; } @property (assign) Util *utils; @end Finally, in the ViewController.m, I do the following: #import "Util.h" @implementation MyViewController @synthesize utils; - (void)viewDidLoad { [super viewDidLoad]; utils.myMethod; //this doesn't work [utils myMethod]; //this doesn't work either NSLog(@"utils = %@", utils); //in the console, this prints "utils = (null)" } What am I doing wrong? I'd like to not only be able to directly reference other classes/methods in a simple util class like this, but I'd also like to directly reference other ViewControllers and their properties and methods as well. I'm stumped! Please Help.

    Read the article

  • autostart app with tag in awm

    - by nonsenz
    while giving awm a try i encounter some problems. i want to autostart some apps when awm is started with specific tags. here's the relevant config i use for that. first my tags with layouts: tags = { names = {"mail", "www", "video", "files", 5, 6, 7, 8, 9}, layout = {layouts[11], layouts[11], layouts[11], layouts[11], layouts[1], layouts[1], layouts[1], layouts[1], layouts[1]} } for s = 1, screen.count() do -- Each screen has its own tag table. tags[s] = awful.tag(tags.names, s, tags.layout) end now the app-autostart stuff: awful.util.spawn("chromium-browser") awful.util.spawn("firefox") awful.util.spawn("vlc") awful.util.spawn_with_shell("xterm -name files -e mc") awful.util.spawn_with_shell("xterm -name 5term") awful.util.spawn_with_shell("xterm -name 5term") awful.util.spawn_with_shell("xterm -name 5term") awful.util.spawn_with_shell("xterm -name 5term") awful.util.spawn_with_shell("xfce4-power-manager") i use xterm with the -name param to give them custom classes (for custom tags via rules). and now some rules to connect apps with tags: awful.rules.rules = { -- All clients will match this rule. { rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, focus = true, keys = clientkeys, buttons = clientbuttons } }, { rule = { class = "MPlayer" }, properties = { floating = true } }, { rule = { class = "pinentry" }, properties = { floating = true } }, { rule = { class = "gimp" }, properties = { floating = true } }, -- Set Firefox to always map on tags number 2 of screen 1. -- { rule = { class = "Firefox" }, -- properties = { tag = tags[1][2] } }, { rule = { class = "Firefox" }, properties = { tag = tags[1][2] } }, { rule = { class = "Chromium-browser" }, properties = { tag = tags[1][1] } }, { rule = { class = "Vlc"}, properties = { tag = tags[1][3] } }, { rule = { class = "files"}, properties = { tag = tags[1][4] } }, { rule = { class = "5term"}, properties = { tag = tags[1][5] } }, } it works for chromium, firefox and vlc but not for the xterms with the "-name" param. when i check the xterms after they started with xprop i can see: WM_CLASS(STRING) = "5term", "XTerm" i think that sould work, but the xterms are placed on the first workspace/tag.

    Read the article

  • Getting file not found error with pdebuild

    - by user35042
    I am attempting to build a Debian package using pdebuild on my main development server (running Debian wheezy). Here is the command I run: pdebuild --pbuilder cowbuilder --buildresult .. \ --debbuildopts -i -- \ --basepath /var/cache/pbuilder/base-wheezy.cow \ --distribution wheezy --configfile /etc/pbuilder/wheezy This works on other servers, but on one server I get this output: I: using cowbuilder as pbuilder dpkg-buildpackage: source package libexample-orange-util-perl dpkg-buildpackage: source version 0.08 dpkg-buildpackage: source changed by John User <[email protected]> dpkg-source -i --before-build libexample-orange-util-perl fakeroot debian/rules clean dh clean dh_testdir dh_auto_clean dh_clean dpkg-source -i -b libexample-orange-util-perl dpkg-source: info: using source format `3.0 (native)' dpkg-source: info: building libexample-orange-util-perl in libexample-orange-util-perl_0.08.tar.gz dpkg-source: info: building libexample-orange-util-perl in libexample-orange-util-perl_0.08.dsc dpkg-genchanges -S >../libexample-orange-util-perl_0.08_source.changes dpkg-genchanges: including full source code in upload dpkg-source -i --after-build libexample-orange-util-perl dpkg-buildpackage: source only upload: Debian-native package File not found: ../libexample-orange-util-perl_0.08.dsc There is no file ../libexample-orange-util-perl_0.08.dsc, but on other build servers no such file is needed (it gets created by the package build). What is causing this "file not found" error?

    Read the article

  • io Exception error in wordcount example

    - by Anitha
    I have installed Hadoop 1.0.3 in Ubuntu 12.04 version (64bit) based on michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/ . I am trying to run a mapreduce job using the wordcount example. Running the command hduser@ubuntu: $/usr/local/hadoop/bin/hadoop jar hadoop-examples-1.0.3.jar wordcount /user/hduser/gutenberg /user/hduser/gutenberg-output gives the following error: Warning: $HADOOP_HOME is deprecated. Exception in thread "main" java.io.IOException: Error opening job jar: hadoop-examples-1.0.3.jar at org.apache.hadoop.util.RunJar.main(RunJar.java:90) Caused by: java.util.zip.ZipException: error in opening zip file at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:131) at java.util.jar.JarFile.<init>(JarFile.java:150) at java.util.jar.JarFile.<init>(JarFile.java:87) at org.apache.hadoop.util.RunJar.main(RunJar.java:88) Thanks in advance.

    Read the article

  • JBoss deployment throws 'java.util.zip.ZipException: error in opening zip file' on Linux?

    - by Kaushalya
    I thought of posting both the question and the answer for others' knowledge. I deployed a large EAR (contained more than ~1024 jars/wars) on JBoss running with Java 6 on Linux, and the deployment process cried throwing the following exception: java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file) at org.jboss.deployment.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:53) at org.jboss.deployment.MainDeployer.init(MainDeployer.java:901) at org.jboss.deployment.MainDeployer.init(MainDeployer.java:895) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:809) at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782) .... Caused by: java.lang.RuntimeException: java.util.zip.ZipException: error in opening zip file at org.jboss.util.file.JarArchiveBrowser.<init>(JarArchiveBrowser.java:74) at org.jboss.util.file.FileProtocolArchiveBrowserFactory.create(FileProtocolArchiveBrowserFactory.java:48) at org.jboss.util.file.ArchiveBrowser.getBrowser(ArchiveBrowser.java:57) at org.jboss.ejb3.EJB3Deployer.hasEjbAnnotation(EJB3Deployer.java:213) .... This was caused by the 'limit of number of open file descriptors' of Linux/Unix operating systems. The default is 1024. You can check the default value using: ulimit -n To increase the number of open file descriptors (say to 2048): ulimit -n 2048 Check the man page of ulimit for more details.

    Read the article

  • Why does java.util.ArrayList allow to add null?

    - by Alfredo O
    I wonder why java.util.ArrayList allows to add null. Is there any case where I would want to add null to an ArrayList? I am asking this question because in a project we had a bug where some code was adding nulls to the List and it was hard to spot where the bug was. Obviously a NullPointerException was thrown but not until another code tried to access the element. The problem was how to locate the code that added the null object. It would have been easier if the ArrayList throwed an exception in the code where the elements was being added.

    Read the article

  • what is wrong: "value Parsers is not a member of package scala.util.parsing.combinator"?

    - by Nick Fortescue
    I've got the above odd error message that I don't understand "value Parsers is not a member of package scala.util.parsing.combinator". I'm trying to learn Parser combinators by writing a C parser step by step. I started at token, so I have the classes: import util.parsing.combinator.JavaTokenParsers object CeeParser extends JavaTokenParsers { def token: Parser[CeeExpr] = ident } abstract class CeeExpr case class Token(name: String) extends CeeExpr This is as simple as I could make it. The code below works fine, but if I uncomment the commented line I get the error message given above: object Play { def main(args: Array[String]) { //val parser: _root_.scala.util.parsing.combinator.Parsers.Parser[CeeExpr] CeeParser.token val x = CeeParser.token print(x) } } In case it is a problem with my setup, I'm using scala 2.7.6 via the scala-plugin for intellij. Can anyone shed any light on this? The message is wrong, Parsers is a member of scala.util.parsing.combinator.

    Read the article

  • Is having 'Util' classes a cause for concern? [closed]

    - by Matt Fenwick
    I sometimes create 'Util' classes which primarily serve to hold methods and values that don't really seem to belong elsewhere. But every time I create one of these classes, I think "uh-oh, I'm gonna regret this later ...", because I read somewhere that it's bad. But on the other hand, there seem to be two compelling (at least for me) cases for them: implementation secrets that are used in multiple classes within a package providing useful functionality to augment a class, without cluttering its interface Am I on the way to destruction? What you say !! Should I refactor?

    Read the article

  • ConcurrentLinkedQueue$Node remains in heap after remove()

    - by action8
    I have a multithreaded app writing and reading a ConcurrentLinkedQueue, which is conceptually used to back entries in a list/table. I originally used a ConcurrentHashMap for this, which worked well. A new requirement required tracking the order entries came in, so they could be removed in oldest first order, depending on some conditions. ConcurrentLinkedQueue appeared to be a good choice, and functionally it works well. A configurable amount of entries are held in memory, and when a new entry is offered when the limit is reached, the queue is searched in oldest-first order for one that can be removed. Certain entries are not to be removed by the system and wait for client interaction. What appears to be happening is I have an entry at the front of the queue that occurred, say 100K entries ago. The queue appears to have the limited number of configured entries (size() == 100), but when profiling, I found that there were ~100K ConcurrentLinkedQueue$Node objects in memory. This appears to be by design, just glancing at the source for ConcurrentLinkedQueue, a remove merely removes the reference to the object being stored but leaves the linked list in place for iteration. Finally my question: Is there a "better" lazy way to handle a collection of this nature? I love the speed of the ConcurrentLinkedQueue, I just cant afford the unbounded leak that appears to be possible in this case. If not, it seems like I'd have to create a second structure to track order and may have the same issues, plus a synchronization concern.

    Read the article

  • Read next word in java

    - by ArtWorkAD
    Hi, I have a text file that has following content: ac und accipio annehmen ad zu adeo hinzugehen ... I read the text file and iterate through the lines: Scanner sc = new Scanner(new File("translate.txt")); while(sc.hasNext()){ String line = sc.nextLine(); } Each line has two words. Is there any method in java to get the next word or do I have to split the line string to get the words?

    Read the article

  • Jetty with a custom JUL logger

    - by Alan Williamson
    I feel this should be easier, or I am missing something obvious. I am trying to use our custom JUL logging library with Jetty. No matter where I put the JAR file for the custom logger, it is not found. I have tried the usual suspects; /lib/, /lib/ext/, /WEB-INF/lib/ and even manually added it to the classpath. 2011-06-29 15:27:34.518::INFO: Started [email protected]:8080 Can't load log handler "net.aw20.logshot.client.LogShotHandler" java.lang.ClassNotFoundException: net.aw20.logshot.client.LogShotHandler java.lang.ClassNotFoundException: net.aw20.logshot.client.LogShotHandler at java.net.URLClassLoader$1.run(URLClassLoader.java:217) I am starting up Jetty using "-jar start.jar" technique. Searching around, I have spotted a couple of threads that talk about this problem, but with no resolution. Or if there was, they didn't answer with their solution. Can anyone help on this front? Thanks

    Read the article

  • ScheduledThreadPoolExecutor executing a wrong time because of CPU time discrepancy

    - by richs
    I'm scheduling a task using a ScheduledThreadPoolExecutor object. I use the following method: public ScheduledFuture<?> schedule(Runnable command, long delay,TimeUnit unit) and set the delay to 30 seconds (delay = 30,000 and unit=TimeUnit.MILLISECONDS). Sometimes my task occurs immediately and other times it takes 70 seconds. I believe the ScheduledThreadPoolExecutor uses CPU specific clocks. When i run tests comparing System.currentTimeMillis(), System.nanoTime() [which is CPU specific] i see the following schedule: 1272637682651ms, 7858346157228410ns execute: 1272637682667ms, 7858386270968425ns difference is 16ms but 4011374001ns (or 40,113ms) so it looks like there is discrepancy between two CPU clocks of 40 seconds How do i resolve this issue in java code? Unfortunately this is a clients machine and i can't modify their system.

    Read the article

  • Getting User input with Scanner

    - by Giannis
    I am trying to have a scanner take input in a loop. Once the user wants to finish he can exit this loop. I have tried many different ways to do it but there is always some problem. This is the code: Scanner sc = new Scanner(System.in); System.out.println("Continue?[Y/N]"); while (sc.hasNext()&& (sc.next().equals("Y"))) { System.out.println("Enter first name"); String name = sc.nextLine(); System.out.println("Enter surname"); String surname = sc.nextLine(); . . . System.out.println("Continue?[Y/N]"); } } The problem with the code above, which also happens on different methods I tried, is that when the user types Y, the scanner will skip the first input for first name,and jump to the surname. If the user types N the loop stops correctly. Someone can explain the reason this happens, and how to overcome using scanner class? p.s: Doing something like while(sc.nextLine().equals("Y")), will cause the loop to terminate before getting input from user after first run of the loop.

    Read the article

  • Java Executor: Small tasks or big ones?

    - by Arash Shahkar
    Consider one big task which could be broken into hundreds of small, independently-runnable tasks. To be more specific, each small task is to send a light network request and decide upon the answer received from the server. These small tasks are not expected to take longer than a second, and involve a few servers in total. I have in mind two approaches to implement this using the Executor framework, and I want to know which one's better and why. Create a few, say 5 to 10 tasks each involving doing a bunch of send and receives. Create a single task (Callable or Runnable) for each send & receive and schedule all of them (hundreds) to be run by the executor. I'm sorry if my question shows that I'm lazy to test these and see for myself what's better (at least performance-wise). My question, while looking after an answer to this specific case, has a more general aspect. In situations like these when you want to use an executor to do all the scheduling and other stuff, is it better to create lots of small tasks or to group those into a less number of bigger tasks?

    Read the article

  • How to avoid resetting the java Scanner position

    - by Derek
    I have some code that looks more or less like this: while(scanner.hasNext()) { if(scanner.findInLine("Test") !=null) { //do some things }else{ scanner.nextLine(); } } I am using this to parse an ~10MB text file. The problem is, if I put a breakpoint on the while() and the scanner.nextLine(), I can see that sometimes the scanners position (in the debug window) goes back to zero. I think this is causing me some kind of loop blow up, because the regext in findInLine() starts at zero, looks through some amount of text, advancing the position, and then it randomly gets set back to zero, so it has to re-parse all that text again. Any ideas what can be causing that? Am I even doing this the right way? Thanks Some additional info: The Scanner is instantiated from an InputStream. After diubg sine debugging, it appears that there is a HearCharBuffer that Scanner uses and it only allows 1024 characters at a time, and then resets. Is there a way to avoid this, or do things differently? That seems like a small amount of characters to be able to scan. Derek

    Read the article

  • ArrayBlockingQueue exceeds given capacity

    - by Wojciech Reszelewski
    I've written program solving bounded producer & consumer problem. While constructing ArrayBlockingQueue I defined capacity 100. I'm using methods take and put inside threads. And I've noticed that sometimes I see put 102 times with any take's between them. Why does it happen? Producer run method: public void run() { Object e = new Object(); while(true) { try { queue.put(e); } catch (InterruptedException w) { System.out.println("Oj, nie wyszlo, nie bij"); } System.out.println("Element added"); } } Consumer run method: public void run() { while(true) { try { queue.take(); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println("Element removed"); } } Part of uniq -c on file with output: 102 Element removed 102 Element added 102 Element removed 102 Element added 102 Element removed 102 Element added 102 Element removed 102 Element added 102 Element removed 102 Element added 102 Element removed 102 Element added 2 Element removed 2 Element added 102 Element removed 102 Element added

    Read the article

  • Updated data is not loaded in the same browser(using Ajax )

    - by Mouli
    Initilly load some datas into dropdown list. It contain company code and company related fields in Textbox. Using Ajax to load the company related Fields in onchange Function I edit the company related fields and update it. Its updated Successfully then i Click the back button and refresh the browser. I select the updated company form the dropdown list. It always list the old value insted of updated data. I want to show the updated fields into corresponding textbox. This part of coding is to load the companyname into dropdown list <% DBAccess dbAccess = Util.initDatabaseAccess(); ResultSet rs = null; ResultSet rsEdit = null; int updateSuccess = 0; String button = request.getParameter("saveAction"); rs = dbAccess.executeQuery("select companyname,Companycode,companyid from yosemitecompany where cmpstatus=1 order by companyname"); %> My Ajax function <script> function showCompanyDetails(str) { if (str=="") { document.getElementById("CompanyName").innerHTML=""; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { var resValue=new Array(); resValue = xmlhttp.responseText.split("$"); document.getElementById("CompanyName").value=resValue[0]; document.getElementById("StreetName1").value=(resValue[1]!=null && !resValue[1].equalsIgnoreCase("null") && resValue[1].length>0?resValue[1]:""); document.getElementById("StreetName2").value=(resValue[2]!=null && !resValue[2].equalsIgnoreCase("null") && resValue[2].length>0?resValue[2]:""); document.getElementById("City").value=(resValue[3]!=null && !resValue[3].equalsIgnoreCase("null") && resValue[3].length>0?resValue[3]:""); document.getElementById("Zipcode").value=trim((resValue[5]!=null && !resValue[5].equalsIgnoreCase("null") && resValue[5].length>0?resValue[5]:"")); document.getElementById("officePhone").value=(resValue[6]!=null && !resValue[6].equalsIgnoreCase("null") && resValue[6].length>0?resValue[6]:""); document.getElementById("Fax1").value=(resValue[7]!=null && !resValue[7].equalsIgnoreCase("null") && resValue[7].length>0?resValue[7]:""); document.getElementById("email").value=(resValue[8]!=null && !resValue[8].equalsIgnoreCase("null") && resValue[8].length>0?resValue[8]:""); document.getElementById("WebSite").value=(resValue[9]!=null && !resValue[9].equalsIgnoreCase("null") && resValue[9].length>0?resValue[9]:""); document.getElementById("description").value=(resValue[10]!=null && !resValue[10].equalsIgnoreCase("null") && resValue[10].length>0?resValue[10]:""); document.getElementById("companycode").value=resValue[11]; document.getElementById("tempCompanyId").value=resValue[12]; document.getElementById("tempStateId").value=resValue[13]; stateID = resValue[13]; countryID = resValue[14]; processAjaxRequestPost('ajaxRequestPost','SingleListHandler','getCountryListDetails', document.getElementById("tempCompanyId").value); showTimezone(resValue[15]); document.getElementById("userName").value=resValue[16]; document.getElementById("passWord").value=resValue[17]; } } xmlhttp.open("GET","customerDetail.jsp?val="+str,true); xmlhttp.send(); } </script> My Update function <%if(updateSuccess <= 0){ if(button != null && button.equalsIgnoreCase("update")) { String companyCode = request.getParameter("companycode").trim(); String companyName = request.getParameter("CompanyName").trim(); String StreetName1 = request.getParameter("StreetName1").trim(); String StreetName2 = request.getParameter("StreetName2").trim(); String City = request.getParameter("City").trim(); String Zipcode = request.getParameter("Zipcode").trim(); String officePhone = request.getParameter("officePhone").trim(); String Fax1 = request.getParameter("Fax1").trim(); String email = request.getParameter("email").trim(); String WebSite = request.getParameter("WebSite").trim(); String description = request.getParameter("description").trim(); String companyid = request.getParameter("tempCompanyId").trim(); String stateId = request.getParameter("tempStateId").trim(); String timeZone = request.getParameter("timezone").trim(); String uploadCustomerLogo = request.getParameter("uploadCustomerLogo").trim(); String userName = request.getParameter("userName").trim(); String passWord = request.getParameter("passWord").trim(); String smtpInsertFlag = "NO"; String getCompanyId = null; updateSuccess = dbAccess.executeUpdate("update yosemitecompany set companyname='"+com.zoniac.util.Util.deQuoteForSingleQuote(companyName)+"', streetname1='"+com.zoniac.util.Util.deQuoteForSingleQuote(StreetName1)+"', streetname2='"+com.zoniac.util.Util.deQuoteForSingleQuote(StreetName2)+"', cityname='"+com.zoniac.util.Util.deQuoteForSingleQuote(City)+"', zipcode='"+com.zoniac.util.Util.deQuoteForSingleQuote(Zipcode)+"', phonenumber1='"+com.zoniac.util.Util.deQuoteForSingleQuote(officePhone)+"', fax1='"+com.zoniac.util.Util.deQuoteForSingleQuote(Fax1)+"', email1='"+com.zoniac.util.Util.deQuoteForSingleQuote(email)+"', website='"+com.zoniac.util.Util.deQuoteForSingleQuote(WebSite)+"', description='"+com.zoniac.util.Util.deQuoteForSingleQuote(description)+"',timezoneid="+timeZone+", stateid="+stateId+" where companyid='"+companyid+"'"); if(rs != null) { rs = null; dbAccess.close(); } } %> My customerDetail.jsp File <% String val = request.getParameter("val"); DBAccess dbAccess = Util.initDatabaseAccess(); ResultSet rs = null; String outputResult = null; String ff = "NO"; rs = dbAccess.executeQuery("select companyname,streetname1,streetname2,cityname,(select statename from state where stateid = (select stateid from yosemitecompany where companyid ="+val+"))as state,zipcode,phonenumber1,fax1,email1,website,description,companycode,companyid,(select stateid from state where stateid = (select stateid from yosemitecompany where companyid ="+val+"))as statecode,(select countryid from country where countryid =(select countryid from state where stateid = (select stateid from yosemitecompany where companyid ="+val+")))as countryid,timezoneid from yosemitecompany where companyid = "+val+""); if(rs.next()){ outputResult = rs.getString(1)+"$"+rs.getString(2)+"$"+rs.getString(3)+"$"+rs.getString(4)+"$"+rs.getString(5)+"$"+rs.getString(6)+"$"+rs.getString(7)+"$"+rs.getString(8)+"$"+rs.getString(9)+"$"+rs.getString(10)+"$"+rs.getString(11)+"$"+rs.getString(12)+"$"+rs.getString(13)+"$"+rs.getString(14)+"$"+rs.getString(15)+"$"+rs.getString(16); } rs = null; rs = dbAccess.executeQuery("select username,password from EMAILAUTHENTICATIONDETAILS where companyid="+val); if(rs.next()){ ff="YES"; outputResult += "$"+rs.getString(1)+"$"+rs.getString(2); } if(ff.equals("NO")){ outputResult += "$$"; } out.println(outputResult); outputResult = null; ff = "NO"; if(rs!=null) { rs = null; dbAccess.close(); } %>

    Read the article

  • Long primitive or AtomicLong for a counter?

    - by Rich
    Hi I have a need for a counter of type long with the following requirements/facts: Incrementing the counter should take as little time as possible. The counter will only be written to by one thread. Reading from the counter will be done in another thread. The counter will be incremented regularly (as much as a few thousand times per second), but will only be read once every five seconds. Precise accuracy isn't essential, only a rough idea of the size of the counter is good enough. The counter is never cleared, decremented. Based upon these requirements, how would you choose to implement your counter? As a simple long, as a volatile long or using an AtomicLong? Why? At the moment I have a volatile long but was wondering whether another approach would be better. I am also incrementing my long by doing ++counter as opposed to counter++. Is this really any more efficient (as I have been led to believe elsewhere) because there is no assignment being done? Thanks in advance Rich

    Read the article

  • FileNotFound exception

    - by Pratik
    I am trying to read a file in a servlet. I am using eclipse IDE. I get a FileNotFoundException if I provide relative file name. List<String> ls=new ArrayList<String>(); Scanner input = new Scanner(new File("Input.txt")); while(input.hasNextLine()) { ls.add(input.nextLine()); } The same code works if I put the absolute path like this: Scanner input = new Scanner(new File("F:/Spring and other stuff/AjaxDemo/src/com/pdd/ajax/Input.txt")); The Java file and text file are there in the same folder. Does it searches text file in some other folder ?

    Read the article

  • Get scanner to include but ignore quoted text?

    - by user1086516
    Basically my problem is this, I need to parse text where , is the delimiter but anything in " " quotes should not be checked for a delimiter. Is this what the Scanner.skip method is for? I would check it myself but I don't understand how to write a regex pattern in java where the token is something in between two " ". I also want to include any quoted text in the proper token which was delimited by the valid ,.

    Read the article

  • Java Scanner - next String until a | is found

    - by user1375883
    Currently I'm trying to read through some basic cells, in this format: +-------+-------+ | | | +-------+-------+ Now I need to get the string representation of the cell's contents and send it off to another method. The problem is that the cells have no pre-defined length. I'm reading these from a file, so my easiest option should be to just use the Scanner I already have set up. Problem is, I don't really know how for this case. I have a strong feeling that I need to use the pattern somehow, but I'm at a complete loss on how to do it. I could also probably just build it up somehow, but that strikes me as being painfully slow.

    Read the article

  • Show/hide glossary page in YUI

    - by QLiu
    Hello All, I am trying to develop a toggle function like http://www.lutsr.nl/yui/toggle/ But it works a little different as them. When user enters the glossary page, he sees a full list of Alphabet with all the techical terms explaination All — A | B | C | E | G | H | M | P | Q | R | S | T | U | Z | ActiveSync® Microsoft® ActiveSync est l’ application permettant à un pocket pc d’ échanger des informations avec un ordinateur . Le Pocket PC doit utiliser Microsoft Windows Mobile™ ou Windows CE. Bluetooth® Le Bluetooth permet aux informations d’ être transmises entre les appareils électroniques qui ont le Bluetooth. Si vous utilisez le Bluetooth, vous n'avez pas besoin de connecter les périphériques à l'aide de câbles. ............................. If the user clicks B Alphabet, the rest of content will hide, except B. and B will be move to top of the section. If the user clicks All aplphabet, the whole list will be reset. What I have now, it is able to show/hide and listen to click event. Here is my source code: <a href="#A" class ="toggle" rel="A_section,fade,20"> A</a> | <a href="#B" class ="toggle" rel="B_section,fade,20"> B</a> | Script: //Load JavaScript Ready event. this.toggleLinks=YAHOO.util.Dom.getElementsByClassName("toggle"); for(var i=0; i<this.toggleLinks.length; i++) { YAHOO.util.Event.addListener(this.toggleLinks[i], "click", this.animateElements,this); } toggleElements : function(e,controlNode,refEl) { if(controlNode && refEl) { if(YAHOO.util.Dom.hasClass(refEl,"show")) { YAHOO.util.Dom.removeClass(controlNode,"selected"); YAHOO.util.Dom.removeClass(refEl,"show"); } else { YAHOO.util.Dom.addClass(controlNode,"selected"); YAHOO.util.Dom.addClass(refEl,"show"); } } // to disable control node's default behaviour return false; }, animateElements : function(e,obj) { // obj = javascript toggle object // this = link clicked YAHOO.util.Event.preventDefault(e); if(this.rel) { controlNode = this; } if(typeof(controlNode) == "string") { controlNode = YAHOO.util.Dom.get(controlNode); } // objParameters // [0] = object id // [1] = animation type (fade, slide) // [2] = animation duration (seconds) var linkClicked = this; var objParameters = controlNode.rel.split(","); var refEl = YAHOO.util.Dom.get(objParameters[0]); var objStatus = YAHOO.util.Dom.hasClass(refEl,"show"); // if true, object is shown switchClasses = function() { obj.toggleOtherElements(e,linkClicked,refEl); obj.toggleElements(e,linkClicked,refEl); } if(objParameters[1] == "fade") { if(objStatus == true) { var attributes = { opacity: {from: .999, to: 0} } var objAnim = new YAHOO.util.Anim(objParameters[0],attributes); objAnim.useSeconds = false; objAnim.duration = objParameters[2]; objAnim.onComplete.subscribe(switchClasses); objAnim.animate(); } else { YAHOO.util.Dom.setStyle(objParameters[0],"opacity",0); switchClasses(); var attributes = { opacity: {from: 0, to: .999} } var objAnim = new YAHOO.util.Anim(objParameters[0],attributes); objAnim.useSeconds = false; objAnim.duration = objParameters[2]; objAnim.animate(); } } else if (objParameters[1] == "slide") { // not implemented yet } else { // NO ANIMATION - switch classes switchClasses(); } }, toggleOtherElements : function(e,linkClicked,refEl) { // toggle selected state of other elements pointing to the same source for(var i=0; i<this.toggleLinks.length; i++) { var objParameters = this.toggleLinks[i].rel.split(","); var linkClickedParameters = linkClicked.rel.split(","); if(objParameters[0] == linkClickedParameters[0]) { if(YAHOO.util.Dom.hasClass(this.toggleLinks[i],"selected")) { YAHOO.util.Dom.removeClass(this.toggleLinks[i],"selected"); } else { YAHOO.util.Dom.addClass(this.toggleLinks[i],"selected"); } } } }

    Read the article

  • log file is not getting created using JDK logging with Commons-logging

    - by Saida Dhanavath
    When I run the TestJcLLoggingService class log messages are coming to Console but no log file is created, please help me if you know the answer. two source files are pasted below. TestJcLLoggingService.java package com.amadeus.psp.pasd.logging; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Service; @Service public class TestJCLLoggingService { private static Log psp_log = LogFactory.getLog(TestJCLLoggingService.class); public static String testJCLLoggingServiceMethod(){ psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService"); psp_log.info("start of method testJCLLoggingServiceMethod class TestJCLLoggingService"); return "This is a test string for JCLLogging"; } public static void main(String[] args){ testJCLLoggingServiceMethod(); } } logging.properties handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler .level = ALL com.amadeus.psp.pasd.level=ALL java.util.logging.ConsoleHandler.level = ALL java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter java.util.logging.FileHandler.pattern = %h/java%u.log java.util.logging.FileHandler.level=ALL java.util.logging.FileHandler.limit=50000 java.util.logging.FileHandler.count=1 java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter java.util.logging.FileHandler.append=true Thanks in advance.

    Read the article

  • Reasons of getting a java.lang.VerifyError

    - by JeroenWyseur
    I'm investigating the following java.lang.VerifyError java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILjava/util/Collection;Ljava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;Lorg/apache/struts/util/MessageRe˜̴MtÌ´MÚw€mçw€mp:”MŒŒ at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) It occurs when the jboss server in which the servlet is deployed is started. It is compiled with jdk-1.5.0_11 and I tried to recompile it with jdk-1.5.0_15 without succes. That is the compilation runs fine but when deployed, the java.lang.VerifyError occurs. When I changed the methodname and got the following error: java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/r eport/DisplayReportServlet, method: getMD signature: (IILjava/util/Collection;Lj ava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;L org/apache/struts/util/MessageResources-á+ÿ+àN|+ÿ+àN+Üw-Çm+ºw-ÇmX#+ûM|X+öM at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357 at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) You can see that more of the method signature is shown. The actual method signature is private PgasePdfTable getMonthData(int month, int year, Collection dayTypes, Collection calendarDays, HashMap bcSpecialDays, Collection activityPeriods, Locale locale, MessageResources resources) throws Exception { I already tried looking to it with javap and that gives the method signature as it should be. When my other colleagues check out the code, compile it and deploy it, they have the same problem. When the build server picks up the code and deploys it on development or testing environments (HPUX), the same error occurs. Also an automated testing machine running ubuntu shows the same error during server startup. The rest of the application runs ok, only that one servlet is out of order. Any ideas where to look would be helpful.

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >