Search Results

Search found 32961 results on 1319 pages for 'java webline'.

Page 99/1319 | < Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >

  • Java Filepath Question

    - by JJ Nooby
    I am trying to finish a java program that uploads a file from a client machine to a webserver. The java program is executed with a bat script. I need to pass in a file name to the java program somehow since the filename is different every time. Or can i somehow use %1 instead of the filepath? I dont know.

    Read the article

  • java: libraries for immutable functional-style data structures

    - by Jason S
    This is very similar to another question (Functional Data Structures in Java) but the answers there are not particularly useful. I need to use immutable versions of the standard Java collections (e.g. HashMap / TreeMap / ArrayList / LinkedList / HashSet / TreeSet). By "immutable" I mean immutable in the functional sense (e.g. purely functional data structures), where updating operations on the data structure do not change the original data, but instead return a new instance of the same kind of data structure. Also typically new and old instances of the data structure will share immutable data to be efficient in time and space. From what I can tell my options include: Functional Java Scala Clojure but I'm not sure whether any of these are particularly appealing to me. I have a few requirements/desirements: the collections in question should be usable directly in Java (with the appropriate libraries in the classpath). FJ would work for me; I'm not sure if I can use Scala's or Clojure's data structures in Java w/o having to use the compilers/interpreters from those languages and w/o having to write Scala or Clojure code. Core operations on lists/maps/sets should be possible w/o having to create function objects with confusing syntaxes (FJ looks slightly iffy) They should be efficient in time and space. I'm looking for a library which ideally has done some performance testing. FJ's TreeMap is based on a red-black tree, not sure how that rates. Documentation / tutorials should be good enough so someone can get started quickly using the data structures. FJ fails on that front. Any suggestions?

    Read the article

  • Block all other input to an application and control it from a wrapper in Java

    - by Oren
    I have a windows application which has a complex GUI that I would like to hide from users. In order to do this, I would like to create a wrapper with an extremely simple interface that overlays this application and automates a number of actions when a user clicks a single button on the wrapper. (I hope "wrapper" is the proper term.) Is it possible to use Java to block input to the underlying application so that users cannot inadvertently mess up the automation? How would I go about this? Also, how can I automate key presses and clicks to the application without hijacking the mouse? Is this possible in Java? I have looked at java.awt.Robot, but it appears to hijack the mouse. I have also looked at AutoIT, but it too hijacks the mouse and does not integrate with Java. Neither of these options seem powerful enough for what I need, but I do not know how else to proceed.

    Read the article

  • How to call java from C++

    - by karikari
    I need to run this line from my c++ program: java -jar test.jar text1 text2 the java app will give a float value and give it to the c++ program. How can I do this? I never call a java stuff before from my ms visual studio C++ file.

    Read the article

  • From C# to JAVA

    - by Newbie
    Hi all, I don't know whether this is a valid question to ask here or not, but I made an attempt. I am basically a C# guy. But since the last 7 days I have been asked to work in java (J2SE 1.4) and I am working in that. and gradually I am finding interest in that. I want to learn more about it and since I am finding a lot of similarity between C# and Java(what ever I have gleaned + worked so far in those 7 days), I am planning to steer my career in that. But having spent for more than 2 years in C# and then moving to java, will it be a problem in future (say after 3/4 months) if I need to change my job.. I mean my most of the exp. lies in C# and just started JAVA. so how the technical panel will accept me if I need to change the platform? Thanks

    Read the article

  • write regex code in java for following data

    - by giri
    <table> <tr> <td style="width:180px"> <a href="/search?q=user:240698+[java]" class="post-tag" title="show all posts by this user in 'java'">java</a><span class="item-multiplier">&times;&nbsp;176</span><br> <a href="/search?q=user:240698+[servlets]" class="post-tag" title="show all posts by this user in 'servlets'">servlets</a><span class="item-multiplier">&times;&nbsp;25</span><br> <a href="/search?q=user:240698+[jsp]" class="post-tag" title="show all posts by this user in 'jsp'">jsp</a><span class="item-multiplier">&times;&nbsp;11</span><br> <a href="/search?q=user:240698+[core]" class="post-tag" title="show all posts by this user in 'core'">core</a><span class="item-multiplier">&times;&nbsp;9</span><br> </tr> </table> from the above code I need to fetch only java, servlets, jsp and core. Can anybody plz help me out to write a regex in java to fetch those? Thanks

    Read the article

  • Java source code generation frameworks

    - by Superfilin
    I have a set of Java 5 source files with old-style Doclet tags, comments and annotations. And based on that I would like to write a generator for another set of Java classes. What is the best way to do that? And are there any good standalone libraries for code analysis/generation in Java? Any shared exprience in this field is appreciated. So, far I have found these: JaxME's Java Source Reflection - seems good, but it does not seem to support annotations. Also it had no release since 2006. Annogen - uses JDK's Doclet generator, which has some bugs under 1.5 JDK. Also it had no releases for a long time. Javaparser - seems good as well and pretty recent, but only supports Visitor pattern for a single class i.e. no query mechanism like in the 2 above packages.

    Read the article

  • Does Java program never crashes

    - by singh
    Hi I am a c++ programmer , I know little bit about java. As in java programmer do not deal with memory directly, in C++ application most of crashes are due to memory corruptions. So an application written in Java will never crash due to memory relate issue. Thanks

    Read the article

  • What are major differences between C# and Java?

    - by enba
    I just want to clarify one thing. This is not a question on which one is better, that part I leave to someone else to discuss. I don't care about it. I've been asked this question on my job interview and I thought it might be useful to learn a bit more. These are the ones I could come up with: Java is "platform independent". Well nowadays you could say there is the Mono project so C# could be considered too but I believe it is a bit exaggerating. Why? Well, when a new release of Java is done it is simultaneously available on all platforms it supports, on the other hand how many features of C# 3.0 are still missing in the Mono implementation? Or is it really CLR vs. JRE that we should compare here? Java doesn't support events and delegates. As far as I know. In Java all methods are virtual Development tools: I believe there isn't such a tool yet as Visual Studio. Especially if you've worked with team editions you'll know what I mean. Please add others you think are relevant. Update: Just popped up my mind, Java doesn't have something like custom attributes on classes, methods etc. Or does it?

    Read the article

  • PDF printing in java

    - by Julia
    Hello, is there a way to print pdf files from a java webapplication on the local printer of the end user (connected via vpn)? The simple lookup of a printer via Java Printing Service always returns printer which are not able to print pdfs. Are there other libs which can be used for printing in java? By the way, just opening the pdf in the browser is not an option, though it must be possible to run scheduled batch printing without user interaction. Thanks in advance

    Read the article

  • isReachable in Java doesn't appear to be working quite the way it's supposed to

    - by Rayne
    I'm using Clojure, but I can read Java, so this isn't a Clojure specific question. This doesn't even seem to be working from Java. I'm trying to implement a bit of a 'ping' function using isReachable. The code I'm using is this: (.isReachable (java.net.InetAddress/getByName "www.microsoft.com") 5000) Translated to Java by a good friend of mine: public class NetTest { public static void main (String[] args) throws Exception{ String host = "acidrayne.net"; InetAddress a = InetAddress.getByName(host); System.out.println(a.isReachable(10000)); } } Both of these return false. I suppose I must be doin' it wrong, but Google research is telling me differently. I'm confuzzled!

    Read the article

  • java: ClassCastException - [Ljava.lang.Long; cannot be cast to java.lang.Long

    - by ufk
    Hello. well.. I use red5 and setting/getting attributes using the IConnection class but tha's really not relevant. 'L' means long in java. so 0L is 0 type Long instead of just '0' which is 0 type Integer. the following error message: stack trace: java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.lang.Long what's the difference between [Ljava.lang.Long and java.lang.Long ? thanks!

    Read the article

  • hibernate executeUpdate IndexOutOfBounds

    - by luke
    I am trying to use an HQL to perform a simple update in hibernate, but i can't seem to get it to work. i have a query template defined as: private static final String CHANGE_DEVICE_STATUS = "UPDATE THING" +"SET ACTIVE = ? " +"WHERE ID = ?"; and then i try to execute it like this: Session s = HibernateSessionFactory.getSession(); Query query = s.createQuery(CHANGE_DEVICE_STATUS); query.setBoolean(0, is_active); query.setLong(1, id); query.executeUpdate(); But now i get this error: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(ArrayList.java:547) at java.util.ArrayList.get(ArrayList.java:322) at org.hibernate.hql.ast.HqlSqlWalker.postProcessUpdate(HqlSqlWalker.java:390) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:164) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884) at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:865) at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:89) .... what am i doing wrong here? I am using hibernate 3.0 UPDATE i changed it to Query query = s.createQuery(CHANGE_DEVICE_STATUS); query.setBoolean(1, is_active); query.setLong(2, id);//<---throws here query.executeUpdate(); without changing anything else but the parameter indexes and i got this: java.lang.IllegalArgumentException: Positional parameter does not exist: 2 in query: UPDATE DEVICE_INSTANCES SET ACTIVE = ? WHERE DEVICE_INSTANCE_ID = ? at org.hibernate.impl.AbstractQueryImpl.setParameter(AbstractQueryImpl.java:194) at org.hibernate.impl.AbstractQueryImpl.setLong(AbstractQueryImpl.java:244) ...

    Read the article

  • Java: calculate linenumber from charwise position according to the number of "\n"

    - by HH
    I know charwise positions of matches like 1 3 7 8. I need to know their corresponding line number. Example: file.txt Match: X Mathes: 1 3 7 8. Want: 1 2 4 4 $ cat file.txt X2 X 4 56XX [Added: does not notice many linewise matches, there is probably easier way to do it with stacks] $ java testt 1 2 4 $ cat testt.java import java.io.*; import java.util.*; public class testt { public static String data ="X2\nX\n4\n56XX"; public static String[] ar = data.split("\n"); public static void main(String[] args){ HashSet<Integer> hs = new HashSet<Integer>(); Integer numb = 1; for(String s : ar){ if(s.contains("X")){ hs.add(numb); numb++; }else{ numb++; } } for (Integer i : hs){ System.out.println(i); } } }

    Read the article

  • Java - Robot keyPress issue

    - by Trimbitas Sorin
    I'm trying to send keystrokes (like a virtual keyboard) from my Java code, but I encounter some issues. It works perfectly on normal applications (for example, Notepad, browsers, etc.), but not on games (fullscreen or windowed mode). This is the stripped code I'm using: import java.awt.Robot; import java.awt.AWTException; import java.awt.event.InputEvent; Robot robot; robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); How can this problem be fixed?

    Read the article

  • NoClassDefFoundError when running java tool under Xcode

    - by pancake
    Hi all, I'm trying to create a Java Tool by using Xcode. I've already changed my build.xml to have Xcode target java 1.6 and not 1.3 so I can use generics. I'm getting no build errors and using 'javac' and 'java' in the terminal works. Now I want it to work in Xcode as well. I keep getting the following error: Exception in thread "main" java.lang.NoClassDefFoundError: MyClass where 'MyClass' is the class containing the main method. It probably has something to do with the classpath, which as the build.xml prescribes is "${bin}". There is a bin folder in my project folder, and it contains all the .class files needed to run the program. If anybody could help me, it'd be great!

    Read the article

  • Getting problem in threading in JAVA

    - by chetans
    In this program i want to stop GenerateImage & MovingImage Thread both... And i want to start those threads from begining. Can u send me the solution? Here is the code........ package Game; import java.applet.Applet; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.MediaTracker; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.net.MalformedURLException; import java.net.URL; public class ThreadInApplet extends Applet implements KeyListener { private static final long serialVersionUID = 1L; Image[] asteroidImage; Image spaceshipImage; String levelstr="Easy Level"; int[] XPos,YPos; int number=0,XPosOfSpaceship,YPosOfSpaceship,NoOfObstacles=5,speed=1,level=1,spaceBtnPressdCntr=0; boolean gameStart=false,pauseGame=false,collideUp=false,collideDown=false,collideLeft=false,collideRight=false; private Image offScreenImage; private Dimension offScreenSize; private Graphics offScreenGraphics; Thread GenerateImages,MoveImages; public void init() { try { GenerateImages=new Thread () //thread to create obstacles { synchronized public void run () { for(int g=0;g<NoOfObstacles;g++) { try { sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } number++; // Temporary counter to count the no of obstacles created } } } ; MoveImages=new Thread () //thread to move obstacles { @SuppressWarnings("deprecation") synchronized public void run () { while(YPos[NoOfObstacles-1]!=600) { pauseGame=false; if(collide()==true) { GenerateImages.suspend(); repaint(); } else GenerateImages.resume(); for(int l=0;l<number;l++) { if(collide()==false) YPos[l]++; else GenerateImages.suspend(); } repaint(); try { sleep(speed); } catch (InterruptedException e) { e.printStackTrace(); } } if(YPos[NoOfObstacles-1]>=600) //level complete state { level++; try { levelUpdation(level); System.out.println("aahe"); } catch (MalformedURLException e) { e.printStackTrace(); } repaint(); } } }; initialPos(); spaceshipImage=getImage(new URL(getCodeBase(),"images/space.png")); for(int i=0;i<NoOfObstacles;i++) { asteroidImage[i]=getImage(new URL(getCodeBase(),"images/asteroid.png")); XPos[i]=(int) (Math.random()*700); YPos[i]=0; } MediaTracker tracker = new MediaTracker (this); for(int i=0;i<NoOfObstacles;i++) { tracker.addImage (asteroidImage[i], 0); } } catch (MalformedURLException e) { e.printStackTrace(); } setBackground(Color.black); addKeyListener(this); } //Sets initial positions of spaceship & obstacle images------------------------------------------------------ public void initialPos() throws MalformedURLException { asteroidImage=new Image[NoOfObstacles]; XPos=new int[NoOfObstacles]; YPos=new int[NoOfObstacles]; XPosOfSpaceship=getWidth()/2-35; YPosOfSpaceship=getHeight()-100; collideUp = false; collideDown=false; collideLeft=false; collideRight=false; } //level finished updations------------------------------------------------------------------------------ @SuppressWarnings("deprecation") public void levelUpdation(int level) throws MalformedURLException { NoOfObstacles=NoOfObstacles+20; speed=speed-3; System.out.println(NoOfObstacles+" "+speed); pauseGame=true; initialPos(); repaint(); } //paint method of graphics to print the messages--------------------------------------------------------- public void paint(Graphics g) { g.setColor(Color.white); if(gameStart==false) { g.drawString("SPACE to start", (getWidth()/2)-15, getHeight()/2); g.drawString(levelstr, (getWidth()/2), getHeight()/2+20); } if(level>1) { if(level==2) levelstr="Medium Level"; else levelstr="High Level"; g.drawString("Level Complete ", (getWidth()/2)-15, getHeight()/2); g.drawString(levelstr, (getWidth()/2), getHeight()/2+20); //g.drawString("SPACE to start", (getWidth()/2)-15, getHeight()/2+40); } for(int n=0;n<number;n++) { if(n>0) g.drawImage(asteroidImage[n],XPos[n],YPos[n],this); } g.drawImage(spaceshipImage,XPosOfSpaceship,YPosOfSpaceship,this); } //update method of graphics to print the messages--------------------------------------------------------- @SuppressWarnings("deprecation") public void update(Graphics g) { Dimension d = size(); if((offScreenImage == null) || (d.width != offScreenSize.width) || (d.height != offScreenSize.height)) { offScreenImage = createImage(d.width, d.height); offScreenSize = d; offScreenGraphics = offScreenImage.getGraphics(); } offScreenGraphics.clearRect(0, 0, d.width, d.height); paint(offScreenGraphics); g.drawImage(offScreenImage, 0, 0, null); } public void keyReleased(KeyEvent arg0){} public void keyTyped(KeyEvent arg0) {} //---------------------Key pressed event to start game & to move the spaceship-------------------------------------- public void keyPressed(KeyEvent e) { if(e.getKeyCode()==32) { spaceBtnPressdCntr++; if(spaceBtnPressdCntr==1) { gameStart=true; GenerateImages.start(); MoveImages.start(); } } if(gameStart==true) { if(e.getKeyCode()==37) { new Thread () { @SuppressWarnings("deprecation") synchronized public void run () { for(int cnt1=1;cnt1<=10;cnt1++) { if(collide()==true && collideLeft == true) { GenerateImages.suspend(); } else { if(XPosOfSpaceship>0) XPosOfSpaceship--; } } repaint(); } }.start(); } if(e.getKeyCode()==38) { new Thread () { @SuppressWarnings("deprecation") synchronized public void run () { for(int cnt1=1;cnt1<=10;cnt1++) { if(collide()==true && collideUp == true) { GenerateImages.suspend(); } else { if(YPosOfSpaceship>10) YPosOfSpaceship--; } } repaint(); } }.start(); } if(e.getKeyCode()==39) { new Thread () { @SuppressWarnings("deprecation") synchronized public void run () { for(int cnt1=1;cnt1<=10;cnt1++) { if(collide()==true && collideRight == true) { GenerateImages.suspend(); } else { if(XPosOfSpaceship<750) XPosOfSpaceship++; } } repaint(); } }.start(); } if(e.getKeyCode()==40) { new Thread () { @SuppressWarnings("deprecation") synchronized public void run () { for(int cnt1=1;cnt1<=10;cnt1++) { if(collide()==true && collideDown == true) { GenerateImages.suspend(); } else { if(YPosOfSpaceship<550) YPosOfSpaceship++; } } repaint(); } }.start(); } } } //------------------------------Collision checking between Spaceship & obstacles------------------------------ public boolean collide() { int x1,y1,x2,y2,x3,y3,x4,y4; //coordinates of obstacles int a1,b1,a2,b2,a3,b3,a4,b4; //coordinates of spaceship a1 =XPosOfSpaceship; b1=YPosOfSpaceship; a2=a1+spaceshipImage.getWidth(this); b2=b1; a3=a1; b3=b1+spaceshipImage.getHeight(this); a4=a2; b4=b3; for(int a=0;a<number;a++) { x1 =XPos[a]; y1=YPos[a]; x2=x1+asteroidImage[a].getWidth(this); y2=y1; x3=x1; y3=y1+asteroidImage[a].getHeight(this); x4=x2; y4=y3; /********checking asteroid touch spaceship from up direction********/ if(y3==b1 && x4>=a1 && x4<=a2) { collideUp = true; collideDown=false; collideLeft=false; collideRight=false; return(true); } if(y3==b1 && x3>=a1 && x3<=a2) { collideUp = true; collideDown=false; collideLeft=false; collideRight=false; return(true); } /********checking asteroid touch spaceship from left direction******/ if(x2==a1 && y4>=b1 && y4<=b3) { collideLeft=true; collideUp = false; collideDown=false; collideRight=false; return(true); } if(x2==a1 && y2>=b1 && y2<=b3) { collideLeft=true; collideUp = false; collideDown=false; collideRight=false; return(true); } /********checking asteroid touch spaceship from right direction*****/ if(x1==a2 && y3>=b2 && y3<=b4) { collideRight=true; collideLeft=false; collideUp = false; collideDown=false; return(true); } if(x1==a2 && y1>=b2 && y1<=b4) { collideRight=true; collideLeft=false; collideUp = false; collideDown=false; return(true); } /********checking asteroid touch spaceship from down direction*****/ if(y1==b3 && x2>=a3 && x2<=a4) { collideDown=true; collideRight=false; collideLeft=false; collideUp = false; return(true); } if(y1==b3 && x1>=a3 && x1<=a4) { collideDown=true; collideRight=false; collideLeft=false; collideUp = false; return(true); } } return(false); } }

    Read the article

  • Glassfish: Storing Java classes in the docroot folder?

    - by Tom Marthenal
    I'm very new to using Glassfish or JSP. I have this working in NetBeans (which has Glassfish bundled) but when I try to put it on my server which is running Glassfish Server, I really don't know what I'm doing. I can place a JSP file in "domains/domain1/docroot/index.jsp" and it will work when I visit my site, but I can't, for some reason, get Java classes to work. I copied the files in "/build/web/" from the NetBeans project to the docroot folder on my server. The errors I get when I visit the site are: org.apache.jasper.JasperException: PWC6033: Error in Javac compilation for JSP PWC6199: Generated servlet error: string:///index_jsp.java:7: package test does not exist PWC6197: An error occurred at line: 5 in the jsp file: /index.jsp PWC6199: Generated servlet error: string:///index_jsp.java:52: cannot find symbol symbol : class TestClass location: class org.apache.jsp.index_jsp PWC6197: An error occurred at line: 5 in the jsp file: /index.jsp PWC6199: Generated servlet error: string:///index_jsp.java:52: cannot find symbol symbol : class TestClass location: class org.apache.jsp.index_jsp The actual Java class is in "WEB-INF/classes/test/TestClass.class" (it is pre-compiled). I really have no idea what I'm doing wrong so any help is greatly appreciated. Thanks!

    Read the article

  • 2d java Graphics

    - by LukeG
    I am new to java 2d graphics and I have problem handling mouseclick event. Is it possible for you to tell me why there is nothing going on after updating mouse status to clicked ? What I want to do is to change the image in array at 0 2 to another image. Nothing happens tho. Thanks for your help in advance. import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.event.*; import java.awt.*; import javax.swing.ImageIcon; import javax.swing.*; public class Board extends JPanel implements MouseListener { private static boolean[] keyboardState = new boolean[525]; private static boolean[] mouseState = new boolean[3]; private static Image[][] images; Image house; int w = 0; int h = 0; int xPos; int yPos; ImageIcon ii = new ImageIcon(this.getClass().getResource("house.gif")); ImageIcon iii = new ImageIcon(this.getClass().getResource("house1.gif")); public Board() { house = ii.getImage(); h = house.getHeight(null); w = house.getWidth(null); images = new Image[10][10]; for(int i = 0; i < 10; i++) { for(int j = 0; j < 10; j++) { images[i][j] = house; } } } public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; for(int i = 0; i < 10; i++) { for(int j = 0; j < 10; j++) { g2d.drawImage(images[i][j],w*i,h*j,null); } } //g2d.drawImage(house,15,15,null); } public void checkMouse() { if(mouseState[0]) { images[0][2] = iii.getImage(); repaint(); super.repaint(); } } @Override public void mousePressed(MouseEvent e) { mouseKeyStatus(e, true); checkMouse(); } @Override public void mouseReleased(MouseEvent e) { mouseKeyStatus(e, false); repaint(); } public static boolean mouseButtonState(int button) { return mouseState[button - 1]; } private void mouseKeyStatus(MouseEvent e, boolean status) { if(e.getButton() == MouseEvent.BUTTON1) mouseState[0] = status; else if(e.getButton() == MouseEvent.BUTTON2) mouseState[1] = status; else if(e.getButton() == MouseEvent.BUTTON3) mouseState[2] = status; }

    Read the article

  • Line End Problem Reading with Scanner Class in Java

    - by dikbas
    I am not an experienced Java programmer and i'm trying to write some text to a file and then read it with Scanner. I know there are lots of ways of doing this, but i want to write records to file with delimiters, then read the pieces. The problem is so small. When I look the output some printing isn't seen(shown in below). I mean the bold line in the Output that is only written "Scanner". I would be appreciated if anyone can answer why "String: " isn't seen there. (Please answer just what i ask) I couldn't understand if it is a simple printing problem or a line end problem with "\r\n". Here is the code and output: import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class Tmp { public static void main(String args[]) throws IOException { int i; boolean b; String str; FileWriter fout = new FileWriter("test.txt"); fout.write("Testing|10|true|two|false\r\n"); fout.write("Scanner|12|one|true|"); fout.close(); FileReader fin = new FileReader("Test.txt"); Scanner src = new Scanner(fin).useDelimiter("[|\\*]"); while (src.hasNext()) { if (src.hasNextInt()) { i = src.nextInt(); System.out.println("int: " + i); } else if (src.hasNextBoolean()) { b = src.nextBoolean(); System.out.println("boolean: " + b); } else { str = src.next(); System.out.println("String: " + str); } } fin.close(); } } Here is the output: String: Testing int: 10 boolean: true String: two String: false Scanner int: 12 String: one boolean: true

    Read the article

  • N3WB Question: passing objects in java?

    - by Adam Outler
    Hello, I am new at java. I am doing the following: Read from file, then put data into a variable. checkToken = lineToken.nextToken(); processlinetoken() } But then when I try to process it... public static void readFile(String fromFile) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(fromFile)); String line = null; while ((line=reader.readLine()) != null ) { if (line.length() >= 2) { StringTokenizer lineToken = new StringTokenizer (line); checkToken = lineToken.nextToken(); ...... But here's where I come into a problem. public static void processlinetoken() checkToken=lineToken.nextToken(); } it fails out. Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method nextToken() is undefined for the type String at testread.getEngineLoad(testread.java:243) at testread.readFile(testread.java:149) at testread.main(testread.java:119) so how do I get this to work? It seems to pass the variable, but nothing after the . works.

    Read the article

< Previous Page | 95 96 97 98 99 100 101 102 103 104 105 106  | Next Page >