I am unable to find the solution of working with String values in ant/build file. I have 2 values in 2 text field in java project. I need to pick up those two string (text fields) values to the build file.
Example:-
java.io.InputStream inputStream = process.getInputStream() ;
InputStreamReader inputstreamreader = new InputStreamReader(inputStream);
BufferedReader bufferedrReader = new BufferedReader(inputstreamreader);
String strLine = "";
int length = strLine.length();
progressBar.setMaximum(100);
length=progressBar.getValue();
while ((strLine = bufferedrReader.readLine()) != null) {
System.out.println(strLine);
System.setErr(System.out);
String newline = "\n";
textArea.append(strLine+newline);
textArea.setCaretPosition(textArea.SCROLLBARS_VERTICAL_ONLY);
length++;
I have this code with a string. Where is this string value is stored so that i can use its value in ant file.
EDITED
FileNameExtensionFilter filter = new FileNameExtensionFilter("Text Files","txt");
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Choose");
fileChooser.setFileFilter(filter);
// For Directory
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int rVal = fileChooser.showOpenDialog(null);
if (rVal == JFileChooser.APPROVE_OPTION) {
textFieldChoose.setText(fileChooser.getSelectedFile().toString());
String str="";
final JFrame msgframe= new JFrame();
msgframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
str= textFieldChoose.getText();
JOptionPane.showMessageDialog(textFieldChoose, str);
I want to read the value of String str="";
outside any text file from where I can use it in my build file. str is the path value of the selected file "?
Here:
It looks like the code is appending the file content line by line to a JTextArea (or worse, an old AWT TextArea).
In any case, your code is simply updating an UI element.
In other words: all you got is already there. Just dont append the text read from the files to that UI component, but make it available to your ANT task!