Reading text file and display in the selectOnechoice list item In ADF.
Hi,
I have a requirement to read the text field which have list of strings and that string display in the SelectOneChoice List item component on page load.
I am using Jdeveloper 11.1.2.3 version.
Any suggestion will highly appreciated..
Thanks in advance.
Regards
Hi,
Google will produce you with hints on how to read content of a file from Java (ideally the file uses some delimiter). Then in a managed bean, you read the file and save its content in a list of SelectItem. So your managed bean should have the following property and setter/getter pairs
ArrayList<SelectItem> listFromFile = new ArrayList<SelectItem>();
public void setListFromFile(ArrayList l){ //you don't need this }
public ArrayList<SelectItem> getListFromFile(){
//read file content and iterate over the file list entries
for(i=0, i < fileContent.length, ++i){
SelectItem si = new SelectItem();
si.setValue(... the value to update the list of value with ...);
si.setLabel("... the label to show in the list ...");
listFromFile.add(si);
return listFromFile;
}The af:selectOneChoice component should look as follows
<af:selectOneChoice id=".." value="...attribute to update with selection ..." ...>
<f:selectItems value="#{managedBean.listFromFile}"/>
</af:selectOneChoice>Frank
Similar Messages
-
Reading text file and output (to stdout) a list of the unique words in the
Hi,
I have a main method as
main.java
package se.tmp;
public class Main
public static void main( String[] args )
WordAnalyzer.parse( args[0] );
and text file as
words.txt
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the quick brown fox jumps over the lazy dog
the requirement is like
I need create this WordAnalyzer class, implement the parse method, and then commit the file. This method takes a single parameter, the filename of the file to parse. The method should read this file and output (to stdout) a list of the unique words in the file along with the number of times each appears in the file.
Can anyone please help me on this?
Thanks.Where are you having problems?
-
Read text file and insert into MySQL
Dears,
I need to read text file and then insert the data in the correct column in the MySQL database
example
I have the following text file:
field1=1234 field2=56789 field3=444555
field1=1333 field2=2222 field3=333555
and so on and so forth ,,note that all rows are identical and just the filed value is changed(there is a dilemeter between fields)
how can I read field1,field2 and field3 from text file and insert them in the correct table and column in the database.....
any help?????
thanks for your cooperation
Best RegarsSure.
Which part don't you understand?
1. Reading a text file
2. Parsing the text file contents.
3. Relational databases and SQL.
4. How to create a database.
5. How to connect to a database in Java.
6. How to insert records into the database in Java.
7. How to map Java objects to records in a database.
This is a pretty nice list. Solve complex problems by breaking them into smaller ones.
% -
Reading from a text file and displaying the contents with in a frame
Hi All,
I am trying to read some data from a text file and display it on a AWT Frame. The contents of the text file are as follows:
pcode1,pname1,price1,sname1,
pcode2,pname2,price2,sname1,
I am writing a method to read the contents from a text file and store them into a string by using FileInputStream and InputStreamReader.
Now I am dividing the string(which has the contents of the text file) into tokens using the StringTokenizer class. The method is as show below
void ReadTextFile()
FileInputStream fis=new FileInputStream(new File("nieman.txt"));
InputStreamReader isr=new InputStreamReader(fis);
char[] buf=new char[1024];
isr.read(buf,0,1024);
fstr=new String(buf);
String Tokenizer st=new StringTokenizer(fstr,",");
while(st.hasMoreTokens())
pcode1=st.nextToken();
pname1=st.nextToken();
price1=st.nextToken();
sname1=st.nextToken();
} //close of while loop
} //close of methodHere goes my problem: I am unable to display the values of pcode1,pname1,price1,sname1 when I am trying to access them from outside the ReadTextFile method as they are storing "null" values . I want to create a persistent string variable so that I can access the contents of the string variable from anywhere with in the java file. Please provide your comments for this problem as early as possible.
Thanks in advance.If pcode1,pname1,price1,sname1 are global variables, which I assume they are, then simply put the word static in front of them. That way, any class in your file can access those values by simply using this notation:
MyClassName.pcode1;
MyClassName.pname1;
MyClassName.price1;
MyClassName.sname1 -
hey ppl
i have a datagrid in my form.i need to read input(fields..sort of a database) from a text file and display its contents in the datagrid.
how can this be done.. and also after every few seconds reading event should be re executed.. and that the contents of the datagrid will keep changing as per the changes in the file...
please help as this is urgent and important.. if possible please provide me with an example code as i am completely new to flex...
thanks.....It's not possible to read from a file without using classes from the core API*. You'll have to get clarification from your instructor as to which classes are and are not allowed.
[http://java.sun.com/docs/books/tutorial/essential/io/]
*Unless you write a bunch of JNI code to replicate what the java.io classes are doing. -
Hi i am new to labview
I want to extract data from a text file and display it on the front panel.
How do i proceed??
I have attached a file for your brief idea...
Attachments:
extract.jpg 3797 KBRoopeshV wrote:
Hi,
The below code shows how to read from txt file and display in the perticular fields.
Why have you used waveform?
Regards,
Roopesh
There are so many things wrong with this VI, I'm not even sure where to start.
Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
Not using Read From Spreadsheet File.
Use of local variables to populate an array.
Cannot insert values into an empty array.
What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
Also, how does this answer the poster's question? -
Help! Read raw Image data from a file and display on the JPanel or JFrame.
PLEASE HELP, I want to Read Binary(Raw Image)data (16 bit integer) from a file and display on the JPanel or JFrame.
Hey,
I need to do the same thing. Did you find a way to do that?
Could you sent me the code?
It's urgent, please.
My e-mail is [email protected] -
Include text file and display from text file
Ok. I'm found the site with the monkey on the the flash thing and all it shows is a name, email and something else and I used it and it works by including a txt file and displaying text from that file as putting down this information
name.text = this.name;
and I can't find the site anymore to get help.
I want to know how to include a PHP script that shows this information like this
text=something I need&username=My Name&email=[email protected]
I want to show this stuff on the flash but every time I execute by using it as localhost/test.php, it will show a sentax error.
This is really stressing me out and I need a lot of help on this stuff.
Can someone help me?ok. let me describe something else.
there's 3 text boxes that is dynamic text.
one of them is called name
the other one is called email
and last one is called location
in the text file, it shows this for importing to the flash file
name=My Name&email=EMAIL&location=My Location
When viewing the flash file that you created, it shows the name, it shows the email, and it shows location.
When I do it on my own even with a text file, it keeps on saying that there is an error on line 1.
I found a site that shows how to do it and it shows what to put in a text file, and it shows the action script. On the FLA file that he shows me has a monkey on the flash file and it has 3 text boxes that I described above. As well as the text file, it is the same. I used the example and it worked but I can't find the example again. I don't know what happened to the website and I don't know what happened to the download I had but it is not downloaded any more. I have adanced systemcare pro so it clears out my recent web searches and my recent downloads so I can't find it. I did a google search on anything about action scripts. I even did a monkey action script search and I couldn't find it.
It's making me mad and I don't know what to do. This is stressing me out way more than you think.
UPDATE:
I did a google search on a file I found in my www folder and I found it. finally.
Here's the site.
http://www.kirupa.com/developer/mx/externaldata.htm
now, I need to figure out how to load it from a PHP file. -
Program to read html file and to open the links in that html file
program to read html file and to open the links in that html file..
ex:- to read automatically all next links in the html file and save it hard diskStart here;
http://java.sun.com/products/jfc/tsc/articles/bookmarks/
It gives you all of the information you need to parse the HTML file using the HTMLEditorKit that is a part of the Java SDK.
Once you get the links from the file, then you can think about connecting to each. -
Having trouble reading specific lines from a text file and displaying them in a listbox
I am trying to read specific lines from all of the text files in a folder that are reports. When I run the application I get the information from the first text file and then it returns this error: "A first chance exception of type 'System.ArgumentOutOfRangeException'
occurred in mscorlib.dll"
Below is the code from that form.
Option Strict On
Option Infer Off
Option Explicit On
Public Class frmInventoryReport
Public Function ReadLine(ByVal lineNumber As Integer, ByVal lines As List(Of String)) As String
Dim intTemp As Integer
intTemp = lineNumber
Return lines(lineNumber - 1)
lineNumber = intTemp
End Function
Public Function FileMatches(ByVal folderPath As String, ByVal filePattern As String, ByVal phrase As String) As Boolean
For Each fileName As String In IO.Directory.GetFiles(folderPath, filePattern)
If fileName.ToLower().Contains(phrase.ToLower()) Then
Return True
End If
Next
Return False
End Function
Private Sub frmInventoryReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim intcase As Integer = 1
Dim strTemp, strlist, strFile As String
Dim blnCheck As Boolean = True
strFile = "Report Q" & intcase.ToString & ".txt"
Do While blnCheck = True
strFile = "Report Q" & intcase.ToString & ".txt"
Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
Dim allLines As List(Of String) = New List(Of String)
Do While objReader.Peek <> -1
allLines.Add(objReader.ReadLine())
Loop
objReader.Close()
strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
lstInventory.Items.Add(strlist)
intcase += 1
strTemp = intcase.ToString
strFile = "Report Q" & intcase.ToString & ".txt"
blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
Loop
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim intcase As Integer = 1
Dim strTemp, strlist, strFile As String
Dim blnCheck As Boolean = True
strFile = "Report Q" & intcase.ToString & ".txt"
Do While blnCheck = True
strFile = "Report Q" & intcase.ToString & ".txt"
Dim objReader As New System.IO.StreamReader("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\" & strFile)
Dim allLines As List(Of String) = New List(Of String)
Do While objReader.Peek <> -1
allLines.Add(objReader.ReadLine())
Loop
objReader.Close()
strlist = ReadLine(1, allLines) & "" & ReadLine(23, allLines)
lstInventory.Items.Add(strlist)
intcase += 1
strTemp = intcase.ToString
strFile = "Report Q" & intcase.ToString & ".txt"
blnCheck = FileMatches("E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\", "*.txt", intcase.ToString)
Loop
End Sub
End Class
Sorry I'm just beginning coding and I'm still a noob. Any help is appreciated. Thank you!Ok, so if I'm following this correctly you should be able to just loop through all of the files in that folder whose file name matches the pattern and then read the first 22 lines, recording only the first and the last.
Exactly how you store the animal data probably depends on how you are going to display it and what else you are going to do with it. Is there anything other than name and cage number that should be associated with each animal?
You might want to make a dataset with a datatable to describe the animal, or you might write a class, or you might just use something generic like a Tuple. Here's a simple class example:
Public Class Animal
Public Property Name As String
Public Property Cage As String
Public Overrides Function ToString() As String
Return String.Format("{0} - {1}", Name, Cage)
End Function
End Class
With that you can use a routine like the following to loop through all of the files and read each one:
Dim animals As New List(Of Animal)
Dim folderPath As String = "E:\Furry Friends Animal Shelter Solution\Furry Friends Animal Shelter\"
For Each filePath As String In System.IO.Directory.GetFiles(folderPath, "Report Q?.txt")
Using reader As New System.IO.StreamReader(filePath)
Dim lineIndex As Integer = 0
Dim currentAnimal As New Animal
While Not reader.EndOfStream
Dim line As String = reader.ReadLine
If lineIndex = 0 Then
currentAnimal.Name = line
ElseIf lineIndex = 22 Then
currentAnimal.Cage = line
Exit While
End If
lineIndex += 1
End While
animals.Add(currentAnimal)
End Using
Next
'do something to display the animals list
Then you might bind the animals list to a ListBox, or loop through the list and populate a ListView. If you decided to fill a datatable instead of making Animal instances, then you might bind the resulting table to a DataGridView.
There are lots of options depending on what you want and what all you need to do.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all" -
Read data from text file and displaying on Webdynpro
Hi all,
I need some help. I have a text file with set of name, phonenumbers . I want to know how to display the data using Webdynpro. Could some one help me. help is appreciated and I promise to award points for right answer.
Thank you
MarutiHi Maruti,
just open the file and loop on the rows, here an example::
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
FileReader f = new FileReader("c:
FileName.ext");
while ((s = in.readLine()) != null)
//Here you can put the line into a WD context structure, i.e:
wdContext.currentContoEconomicoFormElement().setField(s);
}catch (Exception e) {.....}
in.close();
f.close();
For any others questions, please, let me know.
Vito -
// Code Help need .. in Reading CSV file and display the Output.
Hi All,
I am a new Bee in code and started learning code, I have stared with Console application and need your advice and suggestion.
I want to write a code which read the input from the CSV file and display the output in console application combination of first name and lastname append with the name of the collage in village
The example of CSV file is
Firstname,LastName
Happy,Coding
Learn,C#
I want to display the output as
HappyCodingXYZCollage
LearnC#XYXCollage
The below is the code I have tried so far.
// .Reading a CSV
var reader = new StreamReader(File.OpenRead(@"D:\Users\RajaVill\Desktop\C#\input.csv"));
List<string> listA = new List<string>();
while (!reader.EndOfStream)
var line = reader.ReadLine();
string[] values = line.Split(',');
listA.Add(values[0]);
listA.Add(values[1]);
listA.Add(values[2]);
// listB.Add(values[1]);
foreach (string str in listA)
//StreamWriter writer = new StreamWriter(File.OpenWrite(@"D:\\suman.txt"));
Console.WriteLine("the value is {0}", str);
Console.ReadLine();
Kindly advice and let me know, How to read the column header of the CSV file. so I can apply my logic the display combination of firstname,lastname and name of the collage
Best Regards,
Raja Village Sync
Beginer CoderVery simple example:
var column1 = new List<string>();
var column2 = new List<string>();
using (var rd = new StreamReader("filename.csv"))
while (!rd.EndOfStream)
var splits = rd.ReadLine().Split(';');
column1.Add(splits[0]);
column2.Add(splits[1]);
// print column1
Console.WriteLine("Column 1:");
foreach (var element in column1)
Console.WriteLine(element);
// print column2
Console.WriteLine("Column 2:");
foreach (var element in column2)
Console.WriteLine(element);
Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP] -
How can I dynamicall​y read a file and show/plot the data in the GUI?
Hi, everyone,
I hope to implement a VI with the following function:
Usually, when we "read a file" in VI and then show the data in the Waveform Chart or other display GUI, the VI will first read and record all of the data from the file and then show them simultaneously. Now, I want to implement a VI, which could read the data from a file and display it in a time series. That is, I can define a "sampling rate" or "reading rate", like 100 data points / second, then the data points could be correspondingly shown in Waveform Chart one by one as the time moves on. The key purpose is to simulate a real-time data collection module using an existing file.
I don't know how to implement this function. Any suggestion and solution are really appreciated.
Thanks.
ZhanpengHeres the same effect, just a different approach :
The code in the red box was used to create data that you would be getting from a file.
What you could do is (shown above) :
- Read all of the data
- Index only one value at a time, and set the 'sampling rate' using a wait in a while loop.
- Build an array using this value, which will simulate collecting data in real time.
- I used an array of the iterations as X-values, because they coincidentally correspond to # seconds in my example
- I then bundled the time array (xvalues) with the values from your file (yvalues)
- Send that bundle to an XY graph
That should work, though you could implement some different logic for different sampling rates.
Let me know if you need a hand with that.
Message Edited by Cory K on 02-26-2009 11:36 AM
Cory K
Attachments:
graph from file.PNG 10 KB -
Reading s file and saving a the dta to an array
Hi,
I have a txt file that is contained of text and numbersso this is the format :
hdfsgfjsgfjsfg
kshfkwhfl
kshfakh
kahflak
Xunit , YUNIT
1,2
2,3
5,4
So I want to read this file and save the numbers to two arrays, here is my code, and it gives error on Ch[i] = result[1]; it also say array out of bound and it gives me the watrning that ReadDile.java overrides a depricated API. hELP:
import java.net.*;
import java.io.*;
import java.util.*;
import java.lang.*;
public class ReadFile {
public static void main(String[] args) throws IOException {
/*Open the file and Read the file
File inputFile = new File("wfmdata.txt");
FileReader in = new FileReader(inputFile); */
FileInputStream fis = new FileInputStream("wfmdata.txt");
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
String c;
String[] T = new String[10012];
String[] CH = new String[10012];
int i=0;
for(;;)
/*Read one line and store it in variable c */
c = dis.readLine();
//if a null line return
if(c != null)
if( (c == "XUNIT , YUNIT"))
continue;
String[] result = c.toString().split(",");
T[i] = result[1];
CH[i] = result [1];
System.out.println( T[i] + "," + "CH" + result.length);
i++;
}else
dis.close();
how would I change the code to get rid of the errors!
there are 10000 lines of numbers(data).
Sanaz,If you are only trying to read in integers i would recommend a different approach. Try using the scanner class. It's new to 1.5 It basically splits up everything in the data source into tokens based on where there is white space. what might interest you is that it has methods to just retrieve primitive types ints, doubles etc.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
you might try something like this. It will ignore strings and just handle integers, based on the format you have given.
import java.util.Scanner;
import java.io.*;
public class ReadFile
public static void readFile() throws FileNotFoundException
Scanner sc = new Scanner(new FileReader("C:\\YourFile.txt")); // set the source of the data and create a scanner object to tokenize the data
int[] xUnit = new int[10012]; // initialise the integer arrays
int[] yUnit = new int[10012];
while (sc.hasNextInt() == false) // checks to see if the next "token" read by the scanner is an integer
sc.next(); // moves onto the next token until an int is found.
for (int count = 0; count < xUnit.length; count ++) // goes through the array until it hits the end
xUnit[count] = sc.nextInt(); //assigns the int to the array
sc.next(); // skips the comma
yUnit[count] = sc.nextInt(); //assigns the next int to the other array
for (int count = 0; count < xUnit.length; count ++)
System.out.println( xUnit[count] + "," + yUnit[count]); //prints out all the data read in
}Bear in mind my java experience is fairly limited, so this may not be what you're after. -
Read Text file and count occurences of certain string
Hello,
I have a text file with lines of data in it. I would like to read this text file and count how many lines match a certain string of text.
For example my text file has this data in it.
dog,blue,big
dog,red,small
dog,blue,big
cat,blue,big
If the certain string of text is "dog,blue,big" then the count would return "2".
Thanks for your helpHello,
Thank you for your post.
I am afraid that the issue is out of support range of VS General Question forum which mainly discusses the usage issue of Visual Studio IDE such as
WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System
and Visual Studio Editor.
I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.
In addition, if you are working with Windows Forms app. please consult on Windows Forms Forum:http://social.msdn.microsoft.com/Forums/windows/en-US/home?category=windowsforms
If you are working with WPF app, please consult on WPF forum:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=wpf
If you are working with ASP.NET Web Application, I suggest that you can consult your issue on ASP.NET forum:
http://forums.asp.net/
for better solution and support.
Visual Studio Language Forums:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/home?category=vslanguages
Best regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
When debugging, a for loop is not entered even though the number 6 is passed to "N".
I cannot figure out why a for loop is not entered when I debug it. When debugging a value of 6 is clearly passed to "N", the number of iterations the loop is supposed to execute. So when I debug, execution highlighting just parses right over the loop
-
Problem recognising duplicates when importing images
I have noted that after moving to version 6, iPhoto will repeatedly allow images that were already imported to be duplicated without giving me the choice of replacing or not. I always used to get a dialog box with a choice to replace or skip. Now I j
-
CRystal 8.5 Pro install asking for Enterprise cd but I only have one CD
The setup screen comes up after registration and says - > Crystal reports has been successfully installed. A web server has been detected. ..... Note : if you are ugrading from Crystal reports 8. the previous web component server has been removed. if
-
RoboHelp HTML - Trying to open any browse or explorer window causes a freeze
Hi, I am using RoboHelp 9 HTML. Trying to open any Browsing window in the project, like the browse button in Insert Image or even a project, not through Recent, causes the application to freeze. I tried uninstalling and re-installing with no luck. Pl
-
Working with dynamic scales in waveform graph - display problem
Hello I want to use the same waveform graph in the frontpanel for different measurements. These measurements contains 1 to 8 curves, some of them I need to autoscale and others I want to use fixed scales. I wrote a method containing these functions a