Now the problem here is it replaces all the occurrence of abc in the string value and I get the below output as :
value=""/xyz_12_1/xyz234/xyz/filename.txt";
However my requirement is only in the case the value exactly matches with source the replacement shd happen. I am expecting the output like this :
String value ="/abc_12_1/abc234/xyz/filename.txt";
Also the above code is in a function which will be called multiple times and the values will keep on changing. However the target and source will remain the same always.
With the code below, I am trying to replace all regex matches for visa cards within a given text file.
My first test was with a text "new3.txt" exclusively containing the visa test card 4111111111111111. My objective was to replace the card with "xxxx-xxxx-xxxx-xxxx". This was successful.
However, when modifying the text file to include other characters and text before and after (ex: " qwerty 4111111111111111 adsf zxcv"), it gives mixed results. Although it successfully validates the match, it replaces the whole text in the file, rather than replacing solely the match.
When trying this search and replace with words (rather than a regex match), it does not have this behavior. What am I missing?
import java.io.*; import java.util.regex.*; public class BTest { //VISA Test private final static String PATTERN = "(?s).*4[0-9]{12}(?:[0-9]{3})?.*"; public static void main(String args[]) { try
so my task is to write a code which would ask user to input the year as integer and first three letters of the month with first being an upper case letter. Than the program would determine the number of days for given year and month.
Currently I have a brain crash on how to check, if the user has provided the month with first character being upper Case. If not, than the program would automatically correct the character. Problem starts at line 17.
import java.util.Scanner;
public class DaysOfMonth4_17 { public static void main (String[] args) { //Initiate scanner Scanner input = new Scanner (System.in); //Ask for year input and use is as INT System.out.println("Enter the year");
public void addEvent(ActionEvent evt) { uname = Util.getUname(); boolean a = EventDAO.add(this); if ( a) { message = "Event has been added!";
[Code] ....
While executing this..i get the following error: ORA-01861: literal does not match format string. Could it be due to any mismatch in date format (chrome browser automatically takes date in the format mm-dd-yyyy )? If yes, how do I resolve it? (I'm using Oracle database)
I have a table which contains list of regular expression and its corresponding value.I have to fetch those value and put it HASHMAP where regex as key.I have to compare the each key with the given string(input) and If matches I have to get the corresponding Value for the regex.
I have a large text file of 1 GB size. I need to print the line when a matching word is found in a particular line. Below is the code I am using. But if there are many lines that has the matching word, it's taking lot of time. Any solution to print the lines much faster.
Scanner scanner = new Scanner(file); while (scanner.hasNextLine()) { String line = scanner.nextLine(); if(line.contains("xyz")) { System.out.println(line); } }
So obviously I'm new to java and i need to write a program that gives exact change in quarters, dimes, nickels, and pennies. For some reason it seems to work correctly but the nickels never is correct and I'm not sure why, seeing as though everything else is.
Java Code:
public class Coins{ private int c; public Coins(int coins){ c = coins; } public void calculate(){ int quarters = c / 25;
I need to write the exact directory path like C:LisaestUpdate to a properties file.
I am trying it by
FileInputStream in = new FileInputStream(test.properties); Properties props = new Properties(); props.load(in); in.close(); FileOutputStream out = new FileOutputStream(newprop.properties); props.setProperty("myDirectory","C:Lisa estUpdate" ); props.store(out, null); out.close();
but the properties file is updated as C:Lisa estUpdate
Extra comes before :.
How can I remove that.
Even I tried it with an command but got same output.
I simply need to write a program that asks a user to input a password. It has to be in this format: DDD-LL-DDDD. The D's mean Digit and the L's stands for Letter. The User has to enter the Hyphens.
If the password isn't entered in that exact format the program should read out a error. If the hyphens aren't entered the program should read out a error. If there are too many characters entered, there should be a error.
import java.util.Scanner; public class security { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter Security Code: "); System.out.println("Use the format: DDD-LL-DDDD and include dashes"); String code = input.next(); char c;
[Code] ....
I'm trying to figure how how to get the code to check if the values entered are in the correct place. I'm also not sure how to make the program check for hyphens. I feel like I'm close though. I can easily add the correct error and valid messages later if I could just figure out this part.
Is there a better way to scan a character array for digits and replace any number in the array with another character ("*") in this case? The array is the address, " 1234 Runner Road " .
how to replace the values in my array with the results of my function factorial.
public static void main(String[] args) { //this is my main function: int[] array = {5,4,3,2,1}; int i = 0; System.out.print("results: "); for (i = 0; i < array.length; i++){ System.out.print(factorial(array[i]));
[code]....
So, what I'm trying to do is change the contents of the array "array" into their factorial value. So, they should be replaced with {120,24,6,2,1}. then add those using linear sum but that's a different story.
I'm currently trying to build a DAO based application where you use a text file as a data source. It have worked out well until I tried to delete lines from the file.
I've managed to fill out the temp file with everything except the line I wanted to remove, but when I try to replace the original file with the temp file it won't work. It casts the error: "temp.txt -> databilar.txt".
I've also tried to use the renameTo method without any success...
I have a file which contains certain positions ([a][b]) that require to be placed in a certain multi-dimensional array. For example I might have an array String[][] that is a size of 6x6 but only have values in positions [2][1] and [3][2]. Because it is important for me to maintain the given array size and also do certain actions with the given positions I cannot modify the size. In addition I need to count the surrounding neighbors each element has (including elements that are null). However because some of my further code cant process with null elements I need to remove all null elements with " " (blank).
I am not sure how this is done or if it's even possible. If it is not possible how can I do something as close as possible to my needs?
public class Puppy{ int puppyAge; public Puppy(String name){ // This constructor has one parameter, name. System.out.println("Passed Name is :" + name ); } public void setAge( int age ){ puppyAge = age;
[Code] ....
How do I put 3 values of the each variable without replacing the last inputted one?
Like when I input "Tommy" and input another name "Gerald", "Tommy" won't be replaced by "Gerald" when I input again.
For an array implementation of a Hangman game I have created an array to hold the game board progress. It is initialized as "_ _ _ " where the underscores represent the number of letter in the word to be guessed. I have written the following method to replace underscores with a correct guess. It is functioning correctly in that it is replacing the underscore with a correct character guess, but it is only replacing the first time this letter appears in the word. I.e. for "greed" guessing "e" would only replace the first e: _ _ e _ _how I may be able to fix this issue.
// Updates gameboard from "_" to current guess if guess is correct if (isCorrectGuess(move)==true){ if(inWinningState()==false){ guessProgress[charLocation] = guess;} return true;}
I'm trying to set up a splash screen where a native splash screen is shown initially and then replaced with the stage from my preloader. This is fairly simple to do. I use the below code to get everything lined up properly.
private void alignStage(Stage stage) { SplashScreen splashScreen = SplashScreen.getSplashScreen(); if (splashScreen != null) { // Align the stage based on the current splash location Rectangle bounds = splashScreen.getBounds(); stage.setX(bounds.getX()); stage.setY(bounds.getY());
[Code] ....
The problem I'm having is that my Stage isn't actually shown by the time the commented event gets fired. The API for onShown says:
Called just after the Window is shown.
My guess is the window has transitioned to being shown, but there's a slight delay until it gets rendered on screen. If that's a decent assumption, is there a reliable way I can make sure my preloader stage is visible on screen before I hide the native splash?
The best option I can think of so far is to delay hiding the native splash until the preloader gets the BEFORE_START notification. This works (no flicker), but, since both splash screens are actually visible for a while, using a transparent splash doesn't work very well (which actually isn't too big of a deal).
I have created a gui which accepts username in the text field and once clicking on submit button it fetches user details and throws it on gui via JTable.
But when i click submit for the second time using different username the background process goes well and good the vector that i pass to jtable changes with new data but the values in gui still contain the old data.