写入具有特定X和Y坐标的文件以在JAVA中绘图 [英] Writing to a file with specific X and Y coordinates for graphing in JAVA

查看:95
本文介绍了写入具有特定X和Y坐标的文件以在JAVA中绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否有可能在Java中将字符写入文件中特定行和列的位置?

I'm just wondering if its possible in java to write a character to a file on a specific line and column position?

我正在编写一个处理股票和Renko图的程序,我已经可以解释输入数据并将其转换为一个1和0的字符串.其中1代表上移而0代表下移.我只想使用"|"将其写入文件代表Renko块的字符.

I am writing a program to deal with stocks and Renko graphs, I can already interpret the input data and turn it into a string of one's and zero's. Where a 1 represents a move up and a 0 a move down. I just want to write this into a file using the "|" character to represent a Renko block.

例如,如果我有字符串:01011,我想使文件看起来像这样:

For example if I had the string : 01011 I want to get the file to look like this:

        |
  |   |
|   |  

我只是不知道是否有写特定行的方法.我想要的甚至有可能吗?任何帮助表示赞赏.

I just don't know if there is a way to write on a specific line. Is what I want even possible? Any help is appreciated.

推荐答案

不存在在给定位置将字符插入文本文件的简便方法.但这真的有必要吗?

No there is no easy way to insert a character into textfile at given position. But is it really necessary?

为什么不将绘图区域"建模为具有固定高度和宽度并预先填充空格的二维字符数组?这样,很容易将角色放置在某个位置.完成绘图"后,您可以将二维数组的内容逐个字符地写入文本文件.

Why don't you model your "drawing area" as a two-dimensional character array with a fixed height and width and prefilled with spaces? With this it is easy to put a character at a certain position. And when you are done with "drawing" you can write the contents of your two-dimensional array into a text file character by character.

这篇关于写入具有特定X和Y坐标的文件以在JAVA中绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆