Chris Fetterley

Ranch Hand
+ Follow
since May 13, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Chris Fetterley

I want to check each line to see if it has the value of lineID1. I want to know if there is a way to put all the lines into an array and check it that way.
20 years ago
side note to this...the lines are seperated by a "~"
20 years ago
Ok I'm trying to read a file line by line and then check for instances of the line for display. Well it will read the file in but instead of reading from the line that I want it just reads from the first line...here is a sample of what I have:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
public class testImporter{

String LineID;

public static void main (String args[]) throws Exception {
File file = new File("C:\\Data");
if (!file.exists()) {
System.out.println("Can't read " + file);
}
else {
if (file.isDirectory( )) {
String [] files = file.list( );
for (int i=0; i< files.length; i++) {
String ifile = files[i];
doit (file + File.separator + ifile);
}
}
else {
doit(args[0]);
}
}
}
public static void doit (String ifile) throws Exception {

String lineID1 = "GS";

method12(ifile,lineID1);
}
public static void method12(String ifile, String lineID1) throws Exception {
BufferedReader inData = new BufferedReader(new InputStreamReader(new FileInputStream(ifile)));

String newLine ="\012";
String line = "";
String str1 = "";
String str2 = "";
String fLine = "";

boolean firstTime = true;

while ((line = inData.readLine()) != null) {

fLine = fLine + (firstTime?"":newLine) + line;
if (firstTime) firstTime = false;
}
inData.close();
if (fLine.indexOf(lineID1) >= 0) {

StringTokenizer st = new StringTokenizer(fLine, "|");
String GS = st.nextToken();
String locat2 = st.nextToken();
String Shipto = st.nextToken();
String Shipfrom = st.nextToken();
String locat5 = st.nextToken();
String locat6 = st.nextToken();
String locat7 = st.nextToken();
String locat8 = st.nextToken();
String locat9 = st.nextToken();

System.out.println("there is:" + Shipto);
System.out.println("there is:" + Shipfrom);
}
}
}
This compiles and runs but instead of reading from the second line (where lineID1 is) it just takes the data from the first line. Any Ideas on how to fix this?
20 years ago
I was asked to create a forum and I was wondering if there was any good reference out there as how to set one up?I would prefer to create them with jsp pages but if there is something wrong with doing this let me know. Thanks
20 years ago
JSP
Welcome Vicent!
Testing is one of the things I'm striving to get better at, any tips on how to make testing easier? How does one go about testing a project before it is created? I often have projects given to me with half information and I have to piece it together as I go along. How would I test something like this?
20 years ago
here is what I had to call in the beginning of each page to reference the location... on each page.
public static String location= String.valueOf(Login.locat);
20 years ago
Thanks you were a huge help!! have it working now.
20 years ago
I am designing a three in one application that needs Three different String and int variables throughout it. Screen with a drop down menu that will allow me to select which string and int I want to use and then starts the application normally. There will actually be three different variation of the program...I will put some examples down below.
The drop down menu I have looks like this....
public boolean action(Event event, Object object) {

if (event.target == station) {
String selection = station.getSelectedItem();

if (selection.equals("Choose "))
doChoice0Action();

else if (selection.equals("Station1 "))
doChoice1Action();

else if (selection.equals("Station2 "))
doChoice2Action();
else if (selection.equals("Station3 "))
doChoice3Action();

return(true);
}
else
return(false);
}
public doChoice0Action() {
l = 0;
}
public void doChoice1Action() {
l = 3;
locat = "Station1";
}
public void doChoice2Action() {
l = 1;
locat = "Station2";
}
public void doChoice3Action() {
l = 2;
locat = "Station3";
}
locat is a string and l is an int this is defined in my Login.java page.
what I want now is to have l and locat available for all of my other .java pages. How do I set this up?
20 years ago
Hello Jacquie!
--------------------
Welcome to the Java Ranch!
20 years ago
I want to send a file to a com port (com6). I have never done this before and I am wondering how I should go about doing this. any suggestions?
are all of the columns the same width and height...if not ever consider you might be getting the wrong columns?
20 years ago
well that pretty much sums it up....but I do not want to get rid of the title bar....I can handle the fact that it's there....it was more of a question I was asked that I didn't know the answer to
thanks
20 years ago
basically I want to know how to get rid of it...but still have the function of closing the window.
20 years ago
what does the logic look like for this?
20 years ago