?
Solved

Java and Eclipse

Posted on 2016-09-14
4
Medium Priority
?
40 Views
Last Modified: 2016-09-24
Hi,
I'm new to EE and a novice with Java.   I am in the middle of making changes to an existing piece of Java Code.   My objective is to add a link which points to a csv file which is created in java at the same time it creates the email with same content.   However, I'm using a compiler (Eclipse) which I am totally unfamiliar with.  The code runs server side and generates emails from the network.   I am debugging client side, and do not have the authority to create the emails on my machine. (Generates loads of errors).

When I select the changed section of code and try step into or to display or inspect, I get multiple errors.   Any suggestions on how to test what I changed?   I need to produce the csv file.

Here is the function that I modified.   If you see anything glaring, please point it out.   Or, if you have a work around to run the code for full testing, I would be grateful.    Thank you!

	private String fillFilesProcessedReport(String vendor, String logPath)
	{

		String content ="";
		String line="";
		String[] splitResults;
		ArrayList fileNames = new ArrayList();
		ArrayList fileContents= new ArrayList();
		String fileName="";
		String indexContents="";
		
		maxIndexFileNameLength=19;
		processedCnt=0;
		if(vendorNumber == 0 )
		{
			content += "The following files have been processed succesfully through the LifeFTP Process.\n";
			//content += "Please click here for the excel spreadsheet:  \\\\svdw-img1\\image\\FTP\\LifeFTPCRL\\Logs\\output.csv   \n\n.";
			content += rPad("Vendor",12 )+ rPad("Index File", maxIndexFileNameLength+2) + "File Contents\n";
			content += rPad("----------",12) + rPad("----------", maxIndexFileNameLength+2) + "-------------\n";
		}

		BufferedWriter bw = null;
		
		try
		{
			
			String reportFileName = logPath+ "_FilesProcessedReport.txt";
		
		    log.info("fillFilesProcessedReport(): "+reportFileName);
				
			BufferedReader reportReader = new BufferedReader(new FileReader(reportFileName));	
			line = reportReader.readLine();
			
			File file = new File ("C:/output.csv");
				if (!file.exists()) {
						file.createNewFile();
				}
				
				FileWriter fw = new FileWriter(file);
				bw = new BufferedWriter(fw);
				
			while(line != null)
			{
				splitResults=line.split("\\*");

				if(splitResults[0].length() > maxIndexFileNameLength)
				{
					maxIndexFileNameLength = splitResults[0].length();
					
				}	
				
				fileNames.add(splitResults[0]);
				fileContents.add(splitResults[1]);
				processedCnt++;
				line = reportReader.readLine(); 

			}
			reportReader.close();
			

			for(int i = 0; i < fileNames.size(); i++)
			{	
				fileName = (String)fileNames.get(i);
				
				indexContents = (String)fileContents.get(i);
				content += rPad(vendor,12)+ rPad(fileName,maxIndexFileNameLength+2) +indexContents + "\n";
				bw.write(content);
			}
			bw.close();
		}

		catch(Exception ex)
		{
			log.error("fillFilesProcessedReport(): " + ex.toString());
			return content;
		}
		
		return content;
        
	}
	

Open in new window

0
Comment
Question by:Michelle Aycoth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 41802359
Maybe you tell the errors? It is hard to guess from small code sniplet
0
 

Accepted Solution

by:
Michelle Aycoth earned 0 total points
ID: 41804591
Found the error:
File file = new File ("C:/output.csv");

Couldn't write out to my C drive, needed to be C:\temp.  
Thanks anyway.   Michelle
0
 
LVL 62

Expert Comment

by:gheist
ID: 41807261
should be java.io.tmpdir.
0
 

Author Closing Comment

by:Michelle Aycoth
ID: 41813600
No one commented or assisted before I found my own solution.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question