- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
几周前我在这里发布了关于我的工作项目的信息。该项目开始时创建一个简单的小程序,它将接收传入的 ACH 文件并读取每一行。该程序还会要求用户提供“原因代码”和“银行”,这将影响下一步。然后,该程序将以某种方式重新格式化所有数据并将其保存到外部文件中。对于那些不知道的人来说,ACH 只是一个非常具体格式的基于文本的文件。 (每个字符和空格都有其含义。)
我使用一些 GUI 项(Jcombobox、JFileChooser 等)、字符串数组列表、缓冲读取器/写入器以及大量 if/else 语句完成了该任务。
任务现在变得更加复杂,我不知道到底如何开始,所以我想我应该寻求社区的建议。
当 ACH 文件传入时,它将采用如下格式:
101 100000000000000000000000000000
522 00000202020382737327372732737237
6272288381237237123712837912738792178
6272392390123018230912830918203810
627232183712636283761231726382168
822233473498327497384798234724273487398
522 83398402830943240924332849832094
62723921380921380921382183092183
6273949384028309432083094820938409832
82283409384083209482094392830404829304
900000000000000000000000000000000
9999999999999999999999999999999999999
9999999999999999999999999999999999999
(我将用“”数字来引用每一行,例如“1数字”是以1开头的行)
最终的结果是数据行被操作并放入“批处理”中。输出文件以“1数字”开头然后包含一个格式为
的批处理5
6
8
5
6
8
5
6
8
我们继续使用相同的“5 数字”,直到原始文件中其下方的所有 6 都已写入,然后我们转到下一个“5”并处理其下方的“6”。
所以,我现在的项目是创建一个完整的 GUI。用户输入文件后,GUI 将具有某种类型的下拉框或所有“6”数字的类似列表。对于每个号码,应该有另一个下拉框来选择原因代码(有 7 个原因代码)。
基本上,最终目标是:
允许用户根据需要仅选择一定数量的“6”数字。
我可以使用缓冲读取器/写入器来执行此操作吗?我目前使用以下代码将值保存到数组列表中:
while((sCurrentLine = br.readLine()) !=null)//<---------This loop will continue while there are still lines to be read.
{
if (sCurrentLine.startsWith("5")){//<------------------If the line starts with "5"..
listFive.add(sCurrentLine);//<-------------------------Add the line to the array list "listFive".
countFive++;//<---------------------------------------------Increase the counter "countFive" by one.
}else if (sCurrentLine.startsWith("6") && countFive==1){//<---------If the line starts with "6" and countFive is at a value of 1..
listSix.add(sCurrentLine);//<---------------------------------------Add the line to the array list "listSix".
}else if (sCurrentLine.startsWith("6") && countFive==2){//<-----------------If the line starts with "6" and countFive is at a value of 2..
listSixBatchTwo.add(sCurrentLine);//<--------------------------------------Add the line to the array list "listSixBatchTwo".
}else if (sCurrentLine.startsWith("6") && countFive==3){//<-----------------------If the line starts with "6" and countFive is at a value of 3..
listSixBatchThree.add(sCurrentLine);//<------------------------------------------Add the line to array list "listSixBatchThree".
}else if (sCurrentLine.startsWith("6") && countFive==4){//<------------------------------If the line starts with "6" and countFive is at a value of 4..
listSixBatchFour.add(sCurrentLine); //<--------------------------------------------------Add the line to array list "listSixBatchFour".
}else if (sCurrentLine.startsWith("8")){//<-----------------------------------------------------If the line starts with "8"..
listEight.add(sCurrentLine);//<----------------------------------------------------------------Add the line to array list "listEight".
}else if (sCurrentLine.startsWith("1")){//<-----------------------------------------------------------If the line starts with "1"..
one = sCurrentLine;//<-------------------------------------------------------------------------------Save the line to String "one".
}else if (sCurrentLine.startsWith("9") && count9 == 1){//<---------------------------------------------------If the line starts with "9" and count9 is at a value of 1..
nine = sCurrentLine;//<-------------------------------------------------------------------------------------Save the line to String "nine".
count9 = 0;//<--------------------------------------------------------------------------------------------------Set count9 to a value of 0.
}else if (sCurrentLine.startsWith("999") && count9 == 0){//<-----------------------------------------------------------If the line starts with "999" and count9 is at a value of 0..
listNine.add(sCurrentLine);//<---------------------------------------------------------------------------------------Add the line to array list "listNine".
}else{
}
}
如果有人能指出我可以从哪里开始,我将非常感激。如果您需要更多信息,请告诉我。
更新:
这是我的 JOptionPane 决策示例。
String[] choices = {"Wells Fargo", "Bank of America", "CitiBank", "Wells Fargo Legacy", "JPMC"};
String input = (String) JOptionPane.showInputDialog(null, "Bank Selection", "Please choose a bank: ", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);
if (input.equals("Wells Fargo"))
{
bank = "WELLS FARGO";
}else if (input.equals("Bank of America")){
bank = "BANK OF AMERICA";
}else if (input.equals("CitiBank")){
bank = "CITI BANK";
}else if (input.equals("Wells Fargo Legacy")){
bank = "WELLS FARGO LEGACY";
}else if (input.equals("JPMC")){
bank = "JPMC";
}
}else{
}
假设我想使用缓冲写入器将所有“6”数字保存到字符串数组中,然后将它们放入 GUI 中的下拉框中。我怎样才能做到这一点?
最佳答案
Can you use the input from Buffered Writer in a GUI..
嗯,BufferedWriter 不是用于获取输入而是用于输出信息,但假设您指的是 BufferedReader,那么答案肯定是肯定的。了解 GUI 和使用 BufferedReader 获取数据是正交的概念——它们都可以独立工作。涉及使用具有 GUI 的 Buffered 读取数据的主要问题
Say a JOptionPane for example.
我不确定您在这里的意思或这之间有何关系。
If yes, then how could I go about doing that? In all the examples I have seen and tutorials about JOptionPane everything is done BEFORE the main method. What if I need if statements included in my JOptionPane input? How can I accomplish this?
我不确定你所说的“一切都在主要方法之前完成”是什么意思,但听起来你可能有点超前了。在担心具体细节和代码的具体位置之前,请考虑您的程序将具有哪些类/对象,以及它们将如何交互 - 即它们将具有哪些方法。
I believe I just had an idea of how I need to proceed first. Can someone please verify? 1. Create static variables representing the lines that will be read. (Such as a static ArrayList.
不,不要立即考虑静态任何事情,因为一旦你这样做了,你就离开了 OOP 领域并进入了过程编程。主要数据应该保存在一个或两个类的实例变量中。
- Create the actual GUI, outside the main Method.
我不确定“在主方法之外”是什么意思,但是 GUI 将由多个类组成,可能是一个主类,并且主类的实例在主方法中或在由 main 方法调用的方法,但在 Swing 事件线程中排队。
- Create the Buffered Reader which will write to the variables mentioned in #1, inside the main method.
再说一次,我不会这样做。 main 方法应该很短,非常短,它存在的原因只是为了启动你的关键对象并让它们运行,仅此而已。不应在其中执行任何重要操作(除了我所说的之外)。您正在考虑小型玩具程序,但这不是您正在编写的内容。 reader 应该是其自己类内的实例变量。它可以由 GUI 通过控制类间接启动,该控制类是响应 GUI 事件的类。如果您在创建 GUI 之前需要数据,那么您将让您的 main 方法创建读取数据的类,要求它获取数据,然后创建 GUI 类,将数据传递给它。
关于java - 一般建议?用于 JAVA 中的 ACH 缓冲读取器/写入器的 GUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32656832/
我有这个代码 var myChart = new FusionCharts("../themes/clean/charts/hbullet.swf", "myChartId", "400", "75
既然写入是立即进行的(复制到内核缓冲区并返回),那么使用 io_submit 进行写入有什么好处? 事实上,它 (aio/io_submit) 看起来更糟,因为您必须在堆上分配写入缓冲区并且不能使用基
我正在使用 mootool 的 Request.JSON 从 Twitter 检索推文。收到它后,我将写入目标 div 的 .innerHTML 属性。当我在本地将其作为文件进行测试时,即 file:
最终,我想将 Vertica DB 中的数据抓取到 Spark 中,训练机器学习模型,进行预测,并将这些预测存储到另一个 Vertica DB 中。 当前的问题是确定流程最后部分的瓶颈:将 Spark
我使用 WEKA 库编写了一个 Java 程序, 训练分类算法 使用经过训练的算法对未标记的数据集运行预测 将结果写入 .csv 文件 问题在于它当前写出离散分类结果(即算法猜测一行属于哪个类别)。我
背景 - 我正在考虑使用 clickonce 通过 clickonce(通过网站)部署 WinForms 应用程序。相对简单的应用程序的要素是: - 它是一个可执行文件和一个数据库文件(sqlite)
是否有更好的解决方案来快速初始化 C 数组(在堆上创建)?就像我们使用大括号一样 double** matrix_multiply(const double **l_matrix, const dou
我正在读取 JSON 文件,取出值并进行一些更改。 基本上我向数组添加了一些值。之后我想将其写回到文件中。当我将 JSONArray 写回文件时,会被写入字符串而不是 JSONArray 对象。怎样才
我为两个应用程序使用嵌入式数据库,其中一个是服务器,另一个是客户端。客户端应用程序。可以向服务器端发送获取数据请求以检索数据并显示在表格(或其他)中。问题是这样的:如何将获取的数据保存(写入)到页面文
是否有更好的解决方案来快速初始化 C 数组(在堆上创建)?就像我们使用大括号一样 double** matrix_multiply(const double **l_matrix, const dou
从问题得出问题:找到所有 result = new ArrayList(); for (int i = 2; i >(i%8) & 0x1) == 0) { result.add(i
由于某种原因,它没有写入 CSV。谁能明白为什么它不写吗? def main(): list_of_emails = read_email_csv() #read input file, cr
关闭。 这个问题是 not reproducible or was caused by typos 。它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能在这里出现,
我目前正在开发一个保存和加载程序,但我无法获得正确的结果。 编写程序: #include #include #define FILENAME "Save" #define COUNT 6 type
import java.io.*; public class Main2 { public static void main(String[] args) throws Exception {
我需要使用预定义位置字符串“Office”从所有日历中检索所有 iOS 事件,然后将结果写入 NSLog 和 UITextView。 到目前为止,这是我的代码: #import "ViewCo
我正在尝试将 BOOL 值写入 PFInstallation 中的列,但会不停地崩溃: - (IBAction)pushSwitch:(id)sender { NSUserDefaults *push
我以前在学校学过一些简单的数据库编程,但现在我正在尝试学习最佳实践,因为我正在编写更复杂的应用程序。写入 MySQL 数据库并不难,但我想知道让分布式应用程序写入 Amazon EC2 上的远程数据库
是否可以写回到ResourceBundle?目前我正在使用 ResourceBundle 来存储信息,在运行时使用以下内容读取信息 while(ResourceBundle.getBundle("bu
关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。 这个问题是由于错别字或无法再重现的问题引起的。虽然类似的问题可能是on-topi
我是一名优秀的程序员,十分优秀!