Writing to a file with specific X and Y coordinates for graphing in JAVA

99封情书 提交于 2019-12-12 04:48:38

问题


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

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.

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.


回答1:


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.



来源:https://stackoverflow.com/questions/29333727/writing-to-a-file-with-specific-x-and-y-coordinates-for-graphing-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!